Skip to content

Translations

James edited this page Oct 26, 2017 · 26 revisions

Translating

All of our translation files can be found in /config/locales. Assuming that you'll be translating from English to a new language, you'll want to duplicate all of the files containing en.yml. We recommend copying and pasting the contents the English files into your new language files and then doing translations line by line.

For example:

back_to_top: Back to Top copied and pasted from en.yml would become back_to_top: Regresar al Inicio in Spanish in es.yml

It is highly recommended that you work on translations with another fluent individual. They don't have to be a developer. Having a second pair of eyes will help catch translation errors!

In every existing main translation file e.g. ptbr.yml, add an entry for the new language

  languages:
     en: English
     es: Español
     ptbr: Português
     sv: Svenska

Adding New Locale to i18n

Add locale initials to:

  • set_locale method in app/controllers/application_controller.rb
  • validates :locale inclusion array in app/models/user.rb
  • config.i18n.available_locales array in config/application.rb
  • the locale shortcut array in config/routes.rb

Add language to announcement banner that shows up on our English pages by updating the translationsAnnouncement method in app/assets/javascripts/announcement.js.

Testing

Please do manual testing. View the app on your local development environment and ensure everything is a-ok.

We have automated tests for i18n to make sure things don't go wrong.

Please add your new translation files to the LOCALES_FILES object in spec/support/compare_locales_support.rb and add tests to spec/compare_locales_support_spec.rb.

Dotting your i's and crossing your t's

Your branch will be out of sync over time, and keys may be changed or added to the master branch. After syncing your branch to master you can run some tools to check against these changes to help identify them. The repository sexybiggetje/ifme-languagetools contains scripts for comparing locales and offers writing style suggestions using a LanguageTool.org instance.

Huge thanks to @sexybiggetje, who translated our site to Dutch, for working on this tool!

Clone this wiki locally