Skip to content
Colin Froggatt edited this page Apr 9, 2018 · 24 revisions

Internationalisation (i18n) and Transifex

The OFN is available in several languages. You can help translating at Transifex.

Transifex and Github integration

Our code is on Github and that is where our source locale en is maintained. To enable people to translate it easily via Transifex, we need to feed it into Transifex and then get the translations back into Github again. Here is the story of the current process. Our main actors are Github, Transifex and our Continuous Integration (CI) server.

Quite regularly, a developer changes some code that involves changing text. Text is changed in the file config/locales/en.yml. Once that change has made it into our production code, the master branch on Github, it needs translating into all the other languages. Transifex is configured to check en.yml on Github every day and make any changes available for translation.

Translators may notice that their language is not 100% translated due to changes of the source file. Then they translate and once a language reaches 100% again, Transifex notifies our CI server.

Our CI server is running txgh to listen to Transifex. When a translation reaches 100%, it will download it from Transifex and push it to Github on the "transifex" branch. There we can check if everything is alright, we can open a pull request and merge the changes into master for the next release.

This process has several flaws and people get utterly confused about the whole thing.

  • If the transifex branch does not exist, our CI server doesn't create it. No translations are automatically pushed to Github and we need to fix this manually.
  • Once a translation reached 100%, Transifex doesn't notify our CI server about any further changes. We need to manually push it to Github.
  • We need to create a pull request for changes on the Transifex branch every release (Github issue). The steps involved for releasing are described here.

The Transifex client is a command line tool that helps with manually downloading translations. After installing, you can replace all locales with the latest Transifex version:

# cd openfoodnetwork
tx pull --force

Development

Clear cache after translation changes

When making changes to config/locales/en.yml or other locals, ensure you reload I18n js translations to see the changes in the application.

rake tmp:cache:clear

Don't duplicate scopes

If scopes are duplicated, they may work in the browser but can result in unrelated failing test.

  shop:
    vegetables:
      carrot: 'carrot'
...
  shop:
    fruit:
      apple: 'apple'

should be:

  shop:
    vegetables:
      carrot: 'carrot'
    fruit:
      apple: 'apple'...

Further reading

Clone this wiki locally