-
Notifications
You must be signed in to change notification settings - Fork 45
Translating a Module (i18n internationalization)
So you have a module, and you want to give it more reach.
Here's how:
Workbench's develop-module
is designed to generate "message files" for you.
Assuming you have your module, helloworld/
, checked out in a directory adjacent to cjworkbench/
:
- In one terminal,
cd cjworkbench && bin/dev develop-module helloworld
. This will start watching for code changes. - Create a directory,
helloworld/locale/
.develop-module
should notice this new directory and write files into it. - Add the
locale/
directory to the Git repository. Commit and push.
You will now have:
-
helloworld/locale/templates/messages.pot
: a file that lets Gettext-compatible translation software add new languages. -
helloworld/locale/en/messages.po
: English translations. -
helloworld/locale/{locale_id}/messages.po
(for each supported locale): Placeholders for other languages.
There will be messages added for all the translatable parts of your module's .yaml
specification: the module's name, description and parameters.
Do not modify the Enlish translations: develop-module
will always overwrite them. You may use Gettext-compatible software to translate the other languages' messages.po
files.
Don't worry about missing translations: they won't cause any crash, and user behavior won't change now that messages.pot
exists. Workbench will fall back to the English message when a non-English message is missing. (All non-English messages are missing at this stage.)
You can use any Gettext-compatible software to edit messages.po
files. At Workbench, we help our users translate using Pontoon.
Here's how we set up a module like helloworld
(after the commit in the "Create message files" section is pushed):
git branch -c pontoon && git push -u origin pontoon
- Browse to https://workbenchdata-i18n.herokuapp.com/admin/projects/ for the "Add project" form
- Enter
name=helloworld
,slug=helloworld
(same slug as in the module spec) - Move "English" (
en
) to the "Read-only" section. MoveGreek
to theLocalizable
section. (Alternatively: "Copy locales from another project" and choosecalculate
.) - Enter repository:
[email protected]:CJWorkbench/helloworld.git
- Enter branch:
pontoon
- Enter download prefix: `https://raw.githubusercontent.com/CJWorkbench/helloworld/locale/{locale_code}
- "Save Project"
- "Sync"
Now you should see helloworld
in the list of projects at https://workbenchdata-i18n.herokuapp.com/admin/
A translator using Pontoon will:
- Log in to https://workbenchdata-i18n.herokuapp.com/projects/
- Click
helloworld
- Click a language
- Click
messages.po
- Use Pontoon's interface to save messages
Every few minutes, Pontoon will (pull and then) push a commit to the pontoon
branch of helloworld
.
A developer responds to Pontoon's branch by:
- Browse to https://github.com/CJWorkbench/helloworld
- Notice GitHub suggests comparing the
pontoon
branch - Create and merge a pull request. DO NOT delete the
pontoon
branch. - Re-import the module in a dev environment, then staging, then production.