Skip to content
Aksel edited this page Jul 30, 2014 · 18 revisions

Setup

We group some apps in to a couple of translation files (PO-files). This way we can

  • Include bluebottle apps
  • Put things that logically fit together together (e.g. all payment stuff or projects + bb_projects) To be able to run translations you should have
  • An account on transifex.com that has rights on OnePercentClub
  • Run pip install transifex-client (op upgrade it if it complains)
  • Make sure .transifexrc is in your home dir and contains something like:

[https://www.transifex.com]
hostname = https://www.transifex.com
password = vasteloavend
token =
username = bartlacroix

Updating translations

To get new translations on the website you should take these steps

  • run ./translations.sh generate. This will create/update English PO files
  • run ./translations.sh push. This will push the PO files to Transifex.
  • Translate untranslated strings on Transifex and mark them as reviewed.
  • run ./translations.sh pull. This will pull all translated PO files.
  • run ./translations.sh compile (from within your env). This compiles the files for Django.
  • Restart your Django development server to see the changes
  • review the translations on your local system.
  • commit all changed PO files to github and deploy it.

Adding a new app to translations

To add an app to translations you have to adjust two files.

  • Add some lines for the app to ./translations.sh in the 'generate' section
  • Add a new entry for the app in .tx/config

After running generate and push the new app should appear in Transifex

Transifex gotchas

Dealing with percentage (%) signs

  • If the translations handle contains a translations (e.g. "The 1%Club") use the {% blocktrans %} templatetag and use two (%%) percentage signs in the Transifex translation
  • If there is no percentage sign in the translation handle (e.g. "Yes please") then a {% trans %} tag with a single % sign in the Transifex translation will work
  • If there is no percentage sign in the translation handle (e.g. "Yes please") then a {% blocktrans %} tag with a two % signs in the Transifex translation is required

Updating translations

  • Pushing .PO files to Transifex overwrites existing translations in Transifex. The "old" translations that are not present in the newly pushed PO files will be lost. When you generate translations locally and push them to Transifex, always make sure the master branch is merged in your work so we are sure no translations are lost.
  • Pushing your .PO files to Transifex via their API may be throttled. Always verify in your command-line that all resources file are pushed to the server.
  • Sometimes the Transifex API / server is down. Always verify in the command line that your translations are actually pushed.

Languages

  • Users can translate translations keys to Dutch and English. On Transifex the English translations are in the language code en_GB. However, on the server we use the "en" code for English. How does that work? When our translation script pulls the translations for en_GB it overwrites the "en" "locale" directory with the PO file from en_GB.

Errors

  • In case of any error, in 90% its the case that your transifex client is outdated. Run "pip install transifex-client --upgrade"
  • Issues with gettext. On Mac X make sure to update your Xcode command line tools. On Ubuntu or other Linux distro make sure you update the relevant gettext compiler.

Transifex dashboard

  • The translations for Onepercent are in the "OnePercentClub" project
  • If you cannot find a translation, make sure that you are searching in the right "resource". Its usually best to search in "All Resources" rather than in specific resources.
  • Alternatively, spend a little bit of time learning the search functionality. It really helps to find translations or to query specific subsets.

Missing translations / Translations not working

  • To "activate" translations the PO files must be compiled and the server restarted. This is done automatically by the deploy script but not locally. Always make sure to compile freshly pulled translations.
  • Translations may also be missing or incorrect because of old stale "locale" dirs. This shouldn't occur very often at all but it may. This can especially be the case on the staging and production server where the deploy script manually copies a tarball with the latest code. There have been cases where the extracted tarball copied the right translations but there was a stale locale directory elsewhere that overwrote the correct translations when the translations were compiled.

Transifex process flow

  • A simple chart that depicts the Transifex flow is located here