-
Notifications
You must be signed in to change notification settings - Fork 124
Translations (internationalization)
Hyrax translates user interface strings into multiple languages, and we can't expect developers to manually translate all i18n strings in their pull requests. (English alone suffices.) To ensure we do not create gaps in Hyrax's translations, we use the i18n-tasks
gem to add missing translations, using the Google Translate API, at release time.
Here are the steps to get up and running with i18n-tasks
:
-
Install
i18n-tasks
: Thei18n-tasks
gem is not a dependency of Hyrax, because the software does not require it (even though we maintainers do), so you can not rely on it being available via bundler. Install it manually viagem install i18n-tasks
. Once it's done, you should be able to execute thei18n-tasks
command (which is safe to run). -
Configure the gem: Assuming you're in the Hyrax directory, you shouldn't need to do anything for this step since Hyrax does ship with
i18n-tasks
configuration atconfig/i18n-tasks.conf
. -
Set up the Google Translate API key: Follow the instructions provided by the
i18n-tasks
gem. Do not add your API key toconfig/i18n-tasks.conf
; store it with the rest of your shell config (e.g.,~/.bashrc
) as a new environment variable calledGOOGLE_TRANSLATE_API_KEY
. -
Run
i18n-tasks
: When you're ready to create and update translations based on the current state of the English strings, runi18n-tasks translate-missing --from en es zh fr it de pt-BR
. (Note that this command may also be used to add languages. If you runi18n-tasks translate-missing --from en ar
, for instance, you will see three new files created:config/locales/hyrax.ar.yml
,config/locales/simple_form.ar.yml
, andlib/generators/hyrax/templates/config/locales/hyrax.ar.yml
.)
Note that i18n-tasks
will not auto-translate our yml.erb files (PATH HERE), so we need to update those manually when necessary (when adding a new language). You will need to hand-create these files. Using Arabic as an example... To do so, copy the English file to a new file using the new language code (ar
), and replace the string at ar.hyrax.select_type.<%= file_name %>.description
from description: "<%= human_name %> works"
to description: "<%= human_name %> أعمال". To get the translated value of the word "works" (as in "works of art", not the present tense conjugation of the verb "to work"), enter the translation (if you speak the language natively) or grab the existing translation from
config/locales/hyrax.ar.ymlat the path of
ar.hyrax.admin.sidebar.works`.