Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Localization

liuche edited this page Oct 12, 2017 · 17 revisions

Firefox Focus for Android is getting localized on Pontoon.

Updating translations

For converting between Android XML files and Gettext PO files (to be consumed by Pontoon) we use a local, slightly modified version of android2po (See tools/l10n/android2po).

Adding strings for translation

New strings are flagged with the strings-approved label, and should be slated for the current milestone. These strings should be added to app/src/main/res/values/strings.xml - include localization notes if necessary for clarity. Remove the strings-approved label once the strings have been added.

Localization Scripts Setup

  1. Python, Pip and Git need to be installed.

    You can optionally set up a virtualenv for running all these scripts in:

    virtualenv <new_env>
    source <new_env>/bin/activate

    Remember to exit the virtualenv when you've finished with everything.

    deactivate
  2. Install the dependencies.

    pip install -r tools/l10n/android2po/requirements.txt

Export strings for translation

  1. You should have a fork of the focus-android-l10n repo in order to make a PR.

  2. Export the string changes into a branch against the focus-android-l10n repo.

    sh tools/l10n/export-strings.sh

    This will clone the l10n Focus repo into the Focus directory if it doesn't already exist, update to the most recent commit, and create a new branch with the string changes per locale in separate commits. The l10n strings repo will be located at $topsrcdir/l10n-repo, and the new branch will be of the format export-YYYY-MM-DD.

  3. Verify that the changes made to locales/templates/app.pot are the strings added.

    Note: Do not be alarmed if there are whitespace changes unrelated to your string changes in the individual language locale files - these are a result of different serializers being used when reading/writing the localization files. There may also be changes in the header items, that are related to the metadata changes made by the POEdit editor.

  4. Add your fork as a remote if it doesn't already exist.

    git remote add <username> [email protected]:<username>/focus-android-l10n.git

  5. Push the branch to your forked repo and make a PR against the mozilla-l10n/focus-android-l10n repo.

    git push <username> <export-branch>

    Since many contributors modify the l10n files, you need to make sure to coordinate with the l10n team because a PR can go stale very quickly and result in conflicts.

Import translated strings

  1. Run the import script with sh tools/l10n/import-strings.sh. This will update the l10n repo (or clone it if it doesn't exist) and import the strings.

    Troubleshooting:

    [values-<locale>/strings.xml] missing placeholder in translation, key: <key_name>

    • This is an error. A placeholder (%1$s) was omitted in the translation. Remove the problematic line/string from the file (it will default to the non-localized string).

    [values-<locale>/strings.xml] number of placeholders not matching, key: <key_name>

    • This is just a warning, and no action needs to be taken.
  2. Verify the changes and then commit and push the updated XML files to the app repository.

Clone this wiki locally