Skip to content

Translations directly through the app.po files

Brian Riley edited this page Mar 6, 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.

Remove the fuzzy comment:

  • DMPRoadmap also makes use of an online translation tool call Pootle which, when downloaded and merged with the codebase, adds some markup to identify translations that it has suggested automatically (without user intervention). These suggested translations include an extra line: #, fuzzy which instructions the system to ignore the translation until it has been verified. If you see this in your app.po file, confirm/fix the translation and remove the #, fuzzy comment line.
#, 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)
  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. Make copies of the following files in 'config/locales' and update accordingly for your language: 'en_US.yml' (note that you only need to translate the dates/times at the very top of this file), 'devise/devise.en_US.yml' (used for sign in, account creation, password resets, etc.), 'bootstrap/en_US.bootstrap.yml', 'contact_us/contact_us.en_US.yml' (used by the Contact page)
  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
  8. Submit a Pull Request back to this repository to get your translations integrated into the core codebase
Clone this wiki locally