Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 2.3 KB

i18n.md

File metadata and controls

58 lines (39 loc) · 2.3 KB

I18n

There are two kind of resources that are localizable.

  • Text in UI like: Map, About, Support, etc.
  • Some data of facilities: services names.

The application is configured with a list of enabled locales that are displayed to the end user.

The current locale is selected by a query string, cookie, browser accepted languages or default application locale.

Adding new localization

Let's suppose we want to add a new fr locale. The following steps should be performed:

  • Create a config/locales/fr.yml with the translated content from config/locales/en.yml
  • Ensure the dataset is enhanced with the fr locale. This means that a name:fr column should be present at data/input/services.csv. Check in importing data for more information.
  • Import the dataset.
  • Enable the fr locale by changing the settings.yml or the SETTINGS__LOCALES__FR=French environment variable.
# file: config/settings.yml
# ...
default_locale: en
locales:
  en: English
  fr: Français

The config/locales/*.yml are translated to javascript thanks to i18n-js gem. So upon deployment a new version of assets will be generated with this resources.

Troubleshooting

In addition to settings.yml file, you can also add locales in other files: settings.local.yml will affect both dev and test environments, while settings/development.yml and settings/test.yml will affect their respective environments only.

If you're currently working with a dataset that supports, let's say English and French, you should disable references to Spanish locale (es) in both settings.local.yml and settings/development.yml. Otherwise, you'll receive the following error when triggering an import from the UI:

/src/app/models/indexing.rb:line_number:in `block in validate_category_group_translations': Missing translation (RuntimeError)

Likewise, if ElasticsearchService specs are failing due to:

Failure/Error: raise "Missing translation"

RuntimeError:
  Missing translation

You can remove the conflicting locale from either settings/test.yml or settings.local.yml.

Locales are managed by Spring. After modifying any of these files, you have to stop the service to force changes to take effect:

bin/spring stop