Skip to content

Translations directly through the app.po files

Brian Riley edited this page Mar 7, 2018 · 16 revisions

Overview

DMPRoadmap uses the FastGettext gem for managing internationalization. Several of the gems however continue to use the standard Rails I18n system so their specific translations files continue to reside in the config/locales/ directory.

How to translate

All translatable text will appear in you language's config/locale/[language code]/app.po file. Open this file and start translating. Be sure to leave the 'msgid' value as is and add your translation to the matching 'msgstr' entry. Here is a sample of entries in the 'es' translation file.

msgid "A pertinent ID as determined by the funder and/or organisation."
msgstr "El ID tal como lo determinó la institución u organismo financiador."

msgid "A required setting has not been provided"
msgstr "No se ha indicado un valor obligatorio"

Notes on translating:

Placeholders:

  • Do not translate any text contained in the %{} placeholders. They are associated with variables defined elsewhere in the system. For example You are now a member of %{organization_name} organization is replaced with the name of the user's organization at run time: You are now a member of University of Somewhere organization.

HTML markup

  • Do not remove any HTML you may see in the translatable text. For example, do not remove the HTML list tags <ol> and <li> found in Steps to login:<ol><li>Click on the 'Sign in' link</li><li>Select the appropriate option</li></ol>
  • Do not add your own HTML markup to translatable text unless the existing translation already contains HTML markup. Text containing HTML markup is handled differently, so the code needs to be changed to allow for HTML markup if it is not already setup to do so.

Fuzzy and Obsolete translations: New translations will be marked "fuzzy", search for this, translate the text and then remove the #, fuzzy line. If you do not remove the line the translation will be ignored.

Obsolete translations are marked with ~#, they usually can be removed completely since they are no longer needed. Remove the entire section, the ~# line and the msgid and msgstr that follow.

Example of a new translation with the #, fuzzy comment:

#, fuzzy
msgid " Share note"
msgstr "Partager la note"

Steps to translate:

  1. Fork this repository and create a new branch for your translations (e.g. ja-translations) git branch -b ja-translations
  2. Run the rake task to ensure that all of the most recent translatable text is identified bundle exec rake gettext:find
  3. Run the rake task to add your language if it does not already exist in 'config/locale/': bundle exec rake gettext:add_language[ja]. (Use the correct ISO-639 language code and include the regional identifier if necessary. For example 'en-US' instead of 'en')
  4. Update the .po file for your language (e.g. 'config/locale/ja/app.po')
  5. Update the translations for the application's plugins: Translating plugins
  6. Add your language identifier to the 'db/seeds.rb' file so that it is available for new installations (optional)
  7. Commit your changes and push your branch back up to Github git commit -a -m "updated translations for ja" and git push origin ja-translations
  8. Submit a Pull Request back to this repository to get your translations integrated into the core codebase. See the Contributing code guide for details on how to submit a PR to DMPRoadmap
Clone this wiki locally