Project

General

Profile

Actions

User interface translations

The user interface was designed with internationalization and localization in mind. Translation are mostly done with gettext but there are exceptions:
  • Translations for CIDOC classes and properties are taken from their specification which is stored in i18n tables in the model schema of the database
  • JavaScript translations either:
    • from their own libraries, e.g. openatlas/static/vendor/jquery_validation_plugin
    • or also via gettext, see e.g. openatlas/templates/util/translations.html

Translations via gettext

Labels and texts are stored in language specific gettext files located in openatlas/translations. These files can be created or edited with e.g. Poedit even by "non programmers".
Because the OpenAtlas team can only provide English and German translations, offers to add other translations are always welcome.

Current translations

Workflow

  • Because of possible merge conflicts, translations should only be done in the develop branch at GitHub
  • For adding new languages the workflow is slightly different and will be done with a new feature/ branch

Update translations

These commands scan the code base and update the language files.

pybabel extract -F openatlas/translations/babel.cfg -k lazy_gettext -o openatlas/translations/messages.pot .
pybabel update -i openatlas/translations/messages.pot -d openatlas/translations

Once updated the language files can be used with Poedit to add/update translations.

Via GitHub pull request

Only the first time
  • Fork the OpenAtlas repository on GitHub
  • Clone it locally and make a branch from develop so that you can work on it
    git checkout develop
    git checkout -b my_branch
    
When updating
  • Update the online develop branch in your GitHub fork. You could do that on GitHub with the Sync fork button after switching to develop (see screenshot below).
  • Switch locally to the develop branch and make sure your local branch is up to date
    git checkout develop
    git pull origin develop
    
  • Switch to your my_branch and make sure it is up to date with the develop one
    git checkout my_branch
    git merge develop
    
  • Run the pybabel update commands from above
  • Make your changes
  • Commit and push your changes
    git add .
    git commit -m "Added translation for XX" 
    git push origin my_branch
    
  • Make a pull request from your my_branch to the OpenAtlas develop branch on GitHub

Additional information

  • Most source texts in the translations files are already 1:1 strings in English but sometimes, e.g. for a longer text it may differ, like for "warning no js".
  • In doubt you can always compare it to existing translations, e.g. for English in the translation folder or at GitHub

Translating the first time

WARNING existing translations will be deleted! In this example with the de parameter for German at the end of the second command:

pybabel extract -F openatlas/translations/babel.cfg -k lazy_gettext -o openatlas/translations/messages.pot .
pybabel init -i openatlas/translations/messages.pot -d openatlas/translations -l de

Location of strings to be translated

Most of the strings to be translated are in the Python and HTML source code marked with an underline function, like e.g.

_('actor')

The Python/JavaScript "switch" for translation needed for JavaScript components is located at openatlas/templates/util/translations.html.

Exception being JavaScript translations for 3rd party code located in openatlas/static/vendor, see README in sub folders there for more details.

Updated by Alexander Watzinger 3 months ago · 20 revisions

Also available in: PDF HTML TXT