Docs: Improved introduction to i18n for Cog authors and Translators #6351
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6351
Loading…
Reference in a new issue
No description provided.
Delete branch "jamesread/docs-i18n-tutorial"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the changes
This is a simple doc PR on the i18n framework page, that hopefully makes translations and internationalization a little more accessible for new Cog authors, and translators.
I confess that I don't actually use the Red project, but simply was helping a friend get started with translations for the first time. I found the docs a bit too brief about how to get started, and think that if there was a bit more explanation about the different types of files, and the ignoring of .mo files, using -'s instead of _'s, and similar, it probably would have been an easier experience.
First time contributor - I've read CONTRIBUTING.md, but my apologies in advance if I've missed a step, as I'm not familiar with this project!
Have the changes in this PR been tested?
Yes (docs only)
Now I see the broken docs tests :-) That's what happens when I write too much asciidoc and markdown. Will put a new commit to fix in a second.
c685f9epushed just now - it just fixes the double-backtick formatting needed for rst, rather than the single-backtick that I'm used to from asciidoc/markdown! I thought this looked somewhat better than the:code:syntax for just highlighting file extensions etc?I don't intend to make any further commits at the moment -- so this is for your review/comments, etc. :-)
@ -7,9 +7,54 @@Internationalization FrameworkThanks a ton for working on this. The majority of the content is good, some parts just need a bit of expansion to fully explain both the "what" and the "why" of the process.
@ -13,0 +16,4 @@that use the framework. The framework is based on the popular gettext format,(with some modifications), which is the standard for providing translations inlots of different software projects.Just calling it "The red framework" in the first line is using an adjective without its noun. Splitting this sentence in two allows it to be explained in a bit more depth, while avoiding a run on.
@ -13,0 +20,4 @@* ``.pot`` files are typically generated by the original author of the cog, andcontain the basic messages in en_US (the language Red is written in), and isused as a template for translators to build their translations on.* ``.po`` files (portable objects) are language specific, for exampleThis section jumps into listing the structure of the files used for translations without any setup. I'm not sure if this needs to be moved, or if it just needs a sentence leading into the content about to be presented.
@ -13,0 +22,4 @@used as a template for translators to build their translations on.* ``.po`` files (portable objects) are language specific, for example``en-GB.po`` for British English, or ``en-ES.po`` for Spanish. Note that Reduses a ``-`` character in the filename, not a ``_`` which is often seen as asLess long winded as two sentences.
@ -13,0 +26,4 @@the standard.* ``locales/`` directory, where ``.po`` files are stored.So, if your are the author of a Cog, or you are adding translations for the firstSomewhere, possibly here, you should link to https://translate.discord.red/. That site is where translators can contribute to Red's core translations, and lists all of the languages Red supports.
@ -13,0 +29,4 @@So, if your are the author of a Cog, or you are adding translations for the firsttime to python code, you would probably generate ``.pot`` files to make your codeeasily translatable. See below for instructions.This sentence is too unsure to be here. At the highest level, translating is a 3 step process:
redgettextredgettextto generate amessages.potfile (must be re-done if strings are changed/added)messages.potfile into alang-code.pofile, and fill out themsgstrs for each string with the appropriate translation for that language/string.At this point in the guide, we only know vaguely what a
.potand.pofile are. We should not already be telling the CC they need to generate a.potfile before they have actually updated the code to support translations. We also should not be implying to translators that they can translate a cog simply by generating a.potfile without touching its code.Realistically there should probably be 3 sections for each of these 3 steps, rather than
For cog creatorsandFor translatorssections.@ -13,0 +41,4 @@other tools, it reads the ``.po`` files directly.~~~~~~~~~~~~~~~For Cog authorsI don't think this paragraph is needed, instead you can introduce
redgettextwhen explaining how to generate.potfiles as a helper provided to make generating them from a cog easier.@ -13,3 +57,4 @@to your ``.py`` code... code-block:: pythonAt this point is when I think it needs a new section header for using
redgettext.I don't love this header name, but I can't think of a better one. "Writing translations" doesn't seem specific enough, but anything else I think of is too wordy.
Rather than saying they need to create a
.pofile for their language, it should probably be explained that either an existing.pofile should be edited or the.potfile can be cloned & renamed with the proper language code to be used as a base. If there is no.potfile, the translator will need to ask the CC to add translation support to their cog.I would suggest adding a small code block example of what a
.pofile looks like, and how to edit it. Additionally, there should be a..warningthat anything within curly braces must be left as-is for the code to function correctly, as those are places where a value is inserted into the string.As mentioned before, Red core (and some third party cogs) do expect users to exclusively use crowdin, rather than PRing in changes directly to
.pofiles. It might make sense to mention that here, or in the next paragraph.@Flame442 , thanks for taking the time to review. I've read through your suggestions and comments, and everything generally sounds fine. Because I've not used the project directly, I'm not familiar with some of the style/conventions, thanks for taking the time to point those out. Happy to revise this PR.
I'll probably just accept all the suggestions batched up into a single commit, and use another commit where a bit more context is called for / more examples are needed, if that approach is OK for you?
Just about to head to bed now, I'll do this when I next get some time available over the next few days.
That sounds fine to me. Let me know when everything is resolved.
@ -13,0 +39,4 @@authors or translators. If you are used to gettext, it is important to explainthat Red does *not use `.mo` files* - it is not necessary to run ``msgfmt`` orother tools, it reads the ``.po`` files directly.It does affect Cog authors in that our tool can extract command docstrings (which are part of cog's UI) while not extracting all the other docstrings (which generally aren't user-facing). This is what the
redgettextusage example listed in this document does and is something that cannot be done withpygettext(which can only do no docstrings or all docstrings). The distinction probably isn't important for translators who just translate whatever.potfile is given to them but is definitely something that Cog authors would want to know.More so,
pygettextwill sometime in the future supports more features thanpygettextwhich is actually rather limited - it has no support for plurals or for context-dependent translations. Those features are already implemented inredgettext(see Cog-Creators/redgettext#9, Cog-Creators/redgettext#10, Cog-Creators/redgettext#11) and just haven't been released yet as I was hoping to have a working implementation of relevant runtime features in Red as well to make sure it aligns with what the support was implemented for.While upstreaming those features to pygettext was mentioned as a possibility (https://discuss.python.org/t/modernize-and-add-missing-features-to-pygettext/26455), a year passed since so it's unclear that there's enough interest to get it there any time soon.
I would suggest just linking to https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html but we actually don't support the majority of that spec yet (the missing features are implemented for redgettext but Red itself lacks support for those constructs) so maybe we will have to wait for that...
Hi!
Any chance you could address the review comments here? Or would you prefer to close it and let someone else get it over the finishing line?