This repository contains the localisations for the KoboToolBox KPI project.
You might be wondering: "I just added a new string to KPI. How do I translate it?" You're in the right place!
To update the KPI UI's translatable sources using Poedit, follow these instructions:
-
⚠️ Do not use version 2 of Poedit! These steps have been tested to work on version 1.8. -
Clone KPI if you have not done so already.
-
From the KPI root directory, run
git submodule update --init --remote --recursive
to retrieve the latest files from thisform-builder-translations
repository. -
Open Poedit. The first time you run it, you'll need to configure it to parse ES6 and CoffeeScript files:
- Enable ES6 parsing:
- Click File, Preferences, and choose the Extractors tab.
- Click JavaScript and click the Edit button.
- Append
;*.es6
to the "List of extensions…" field. - Click OK and close the Preferences window but leave the Preferences window open.
- Enable CoffeeScript parsing. By default,
gettext
doesn't have a CoffeeScript parser, but theC/C++
extractor works fairly well with .coffee files.- Inside the Extractors tab of the Preferences window, click PHP.
- Click the Edit button.
- Append
;*.coffee
to the "List of extensions…" field. - Click OK and close the Preferences window.
N.B.: C/C++ requires all string to be wrapped in double-quotes.
_t('Foo')
won't be detected_t("Foo")
will be detected
- Enable ES6 parsing:
-
Still within Poedit, open the
locale/en/LC_MESSAGES/djangojs.po
(inside the KPI root directory) file with Poedit. We are opening the English file because we're just extracting strings: the actual translation takes place on Transifex.- Ignore the "Language of the translation is the same as source language" warning.
-
Click the Catalog menu and click "Update from Sources". You should see a summary of the new and obsolete strings. Review and save the changes if all looks ok.
-
If you encounter
gettext
parsing error messages (you can see each error's line number in the details), check each error, and if there is a string in that line number that is missing from the sources, you can copy the missed string intojsapp/i18nMissingStrings.es6
and rerun "Update from Sources".
- From the KPI root directory, run
python manage.py makemessages --locale en
. - Verify that new strings appear in
locale/en/LC_MESSAGES/django.po
(inside the KPI root directory).
- Install the Transifex client if you haven't already (
pip install transifex-client
). - From the
locale
directory inside the KPI root, runtx push -s
to push all of the updates to Transifex.
- The Transifex project is called "koboform" and is available at https://www.transifex.com/kobotoolbox/kobotoolbox/.
- From the
locale
directory inside the KPI root, runtx pull --all
; - Commit and push the updates to this repository,
form-builder-translations
, whose root should be thelocale
directory.