Contribute to Program Internationalization

Program internationalization in JAnim includes translating runtime prompts, error messages, CLI text, GUI text, and more.

Note

For program internationalization, English (en) and Chinese (zh_CN) are well maintained. If you need to provide translations for the program in other languages, continue reading this document.

Prepare the Environment

Assume you have already forked the repository and cloned it locally.

Use cd JAnim to enter the project folder, then install the required environment:

pip install -e .

Additionally, make sure GNU gettext is installed.

Workflow

The workflow for program internationalization consists of the following steps:

  1. Update translation files: extract the latest translatable text and generate/update .po files

  2. Translate: edit .po files to perform translation (use format-po to normalize formatting when needed)

  3. Compile translation files: compile .po files into .mo files (only when necessary)

Update Translation Files

To create translations for a new language or update existing translation files, use the following command:

python scripts update-po code <language>

Here <language> is the language code you want to translate to (for example, ja for Japanese, de for German, etc.).

Note

en is the source language of program text, so translation files do not need to be created for it.

After completion, you can find all .po files in the corresponding janim/locale/<language>/LC_MESSAGES/ directory.

Check Translation Progress

Before starting translation or during the process, you can check translation progress:

python scripts check-po code <language>

This command scans all .po files and lists files that still contain untranslated or fuzzy entries. This helps you understand what translation work remains to be done.

Some tools, such as Poedit’s Catalog Manager, can also list translation progress for .po files in a folder.

Translating the Program

Translation files (with the .po extension) are now stored in janim/locale/<language>/LC_MESSAGES/.

You can use Poedit to edit .po files, or edit them directly with any text editor.

If you manually edited many .po files, it is recommended to run this once before submitting:

python scripts format-po code <language>

This command standardizes line wrapping and formatting in .po files, reducing unrelated diffs caused by formatting differences.

After translating, submit your changes and create a Pull Request to merge into the main branch.

Compile Translation Files (Only When Necessary)

If you edit with tools such as Poedit, .mo files are usually compiled automatically after editing. But if you edit .po files directly with a text editor, you need to compile .po files into .mo files manually. You can use:

python scripts compile-po code <language>

Complete Example

Suppose you want to provide a Japanese translation for the program. The complete workflow is as follows:

  1. Update translation files:

    python scripts update-po code ja
    
  2. Edit .po files under janim/locale/ja/LC_MESSAGES/

  3. Check translation progress (optional):

    python scripts check-po code ja
    
  4. Compile translation files (only when necessary):

    python scripts compile-po code ja
    
  5. Test the translation locally (run the program)

  6. (Optional) Normalize .po file formatting before submitting:

    python scripts format-po code ja
    
  7. Submit your changes and open a Pull Request