Skip to content

Localization instructions

pekman edited this page Mar 6, 2012 · 8 revisions

Translation files

All translatable strings are located under config/locales/. There are three kinds of localization systems in use: Gettext, Rails I18n and localized partials.

Gettext

Gettext translations are in gettext subdirectory. They contain translations for strings marked translatable with _() in source code. The application uses fast_gettext.

Gettext files can be edited either with a text editor or with a specialized po-file editor. If editing with a text editor, msgid is the original English string and msgstr is the translation. Untranslated strings have an empty string in msgstr; fast_gettext will display the original English strings for these. Some original strings start with a namespace string and the separator character | (namespace_string|The actual text). The namespace and | character must not be included in the translated string.

Rails I18n

Rails I18n files are in files <locale_id>.yml directly in the locales directory. They contain translations for strings not under application developer's control that come from Rails internal or plugin code, such as model attribute names (used in forms and form error messages).

Rails I18n files are YAML files that contain a hierarchical structure of keys and associated translated strings. The language name shown in locale selector is under the key <locale_id>.i18n.language.name.

Localized partials

Longer texts are in their own partials under partials subdirectory. The directory structure is the same as in app/views/. The files have the language code as a part of their file name, e.g. _longtext.en.html.erb.

Updating Gettext files

When new translatable strings are added or existing ones changed, the Gettext files should be updated with the following command:

rake gettext:find

In order for this to work, Gettext binaries must be installed. In Ubuntu (and probably Debian) this can be done with the command apt-get install gettext.