This document outlines the process for adding and updating translations in redbot.
Suggestions and corrections for the translations in redbot/translations are welcome as GitHub Pull Requests. A few guidelines for doing so:
- Assume a technical audience, but prioritise clarity, accuracy, and brevity. Do not assume deep domain-specific knowledge about HTTP.
- Keep "%(foo)s" style variables in your content.
- Line endings are not important.
In your PR, please do not modify any file except for the .po. Making multiple suggestions in the same PR is fine.
Note that many of REDbot's messages come from the httplint library, which takes i18n PRs too.
Code that contains user-facing strings should follow these guidelines:
- Note Classes: Strings assigned to
_summaryand_textinNoteandRedbotNotesubclasses are automatically extracted. - Other Strings: For other strings (e.g., class attributes, global constants), use the
_lazy translation marker fromredbot.i18n.Ensure these strings are passed tofrom redbot.i18n import _ MY_STRING = _("This is a translatable string")
get_translator().ugettext()(fromredbot.i18n) or used in a context that handles lazy translation before being displayed. - Plurals: Use
ngettextfromredbot.i18nfor strings that have singular and plural forms.from redbot.i18n import ngettext msg = ngettext("%(num)s item", "%(num)s items", count) % {"num": count}
When code changes, new translatable strings might be added. Extract them to the template (redbot/translations/messages.pot):
Run this when you have modified the source code and want to capture new or changed strings.
make i18n-extractUpdate the .po files for all locales to include the new strings from the template:
Run this to propagate the changes from the template to the individual language files.
make i18n-updateYou have two options for translation:
Option A: Manual Translation
Edit the .po files (e.g., redbot/translations/fr/LC_MESSAGES/messages.po) to add missing translations or correct existing ones.
Option B: Auto-Translation
Use an LLM (via the llm package) to automatically translate missing strings. You can specify the model using the MODEL variable (default: mlx-community/aya-23-8B-4bit) and the rate limit using RPM (default: unlimited; this is for remote models).
make i18n-autotranslate MODEL=gemini-2.5-flash-lite RPM=15Note: To use remote models you must have the llm package configured with valid API keys (e.g., ./.venv/bin/llm keys set gemini; see https://ai.google.dev/gemini-api/docs/api-key).
Compile the .po files into binary .mo files for use at runtime:
make i18n-compileRun the tests to verify the translations:
make i18n_testAlternatively, run the local server and visit it with your browser's language set to the target locale:
make serverTo add a new language (e.g., Spanish es):
make i18n-init LANG=esThen follow steps 2-5 above. Once the language is ready, make sure to
- Update the
httplintdependency inpyproject.tomlto a version that supports that language - Update
redbot/18n.pyto list the language inAVAILABLE_LOCALES