Skip to content

Internationalization

danmacpherson edited this page Feb 7, 2013 · 6 revisions

Internationalization

Conductor uses the fast_gettext: https://github.com/grosser/fast_gettext and fast_gettext integration gem for rails gettext_i18n_rails : https://github.com/grosser/gettext_i18n_rails

Using fast_gettext

In source code

To translate a string use:

_("Foo")

To translate string with a parameter use:

_("Bar %s") % param

To translate string with more than one parameters use:

_("Foo %s and %s") % [param1, param2] OR _("Params %{a} and %{b}") % {:a => "Foo", :b => "Bar"}

Tell to gettext - this string need translation (found during parsing, usage i.e. constant string, validation messages):

N_("FooBar")

To translate pluralized:

n_("Apple","Apples",count)

For date and time we use default Rails i18n API:

t('datetime.distance_in_words.x_months', :count => months)

All default translation dictionary is located in src/config/locales/default/en.yml

Format of PO Files

Be sure that added string contains no interpolation.

i.e. for instance states we used

t("instances.states.#{instance.state}")

but it have to be like for gettext format

_(instance.state)

where all states are defined somewhere in project (via gettext method N*). Be sure that your string followed PO file entry’s schematic structure:

msgid untranslated-string
msgstr translated-string

Find new gettext translations

When you add some new string/s use:

$ rake gettext:find

When you add new attribute to the model use:

$ rake gettext:store_model_attributes

then to add new attributes to .pot/.po files:

$ rake gettext:find

If you want to create new .po file for specific language use:

$ rake gettext:add_language[de] 

New translations will be marked fuzzy, search for this and remove it, so that they will be used. Obsolete translations are marked with ~#, they usually can be removed since they are no longer needed.

Translation of english dictionaries

We are using Zanata project https://translate.zanata.org/zanata/ . Here you can find information about starting to contribute in translations.

Our dictionaries contributors can find here: https://translate.zanata.org/zanata/project/view/aeolus-conductor

Export/Import dictionaries to/from Zanata project

Zanata accepts PO file format.

Prerequisites

Export

Create a new version of aeolus-conductor

$ zanata version create VERSION*\#

Set languages that en.yml will be translated to, then download zanata.xml (AFAIK It can be downloaded only through UI)

Push to Zanata (from dir where you have zanata.xml file stored)

$ zanata push --project-type podir --srcdir path_to_directory_with_po_files

Import

Pull from Zanata (from dir where you have zanata.xml file stored)

$ zanata pull --project-type podir

Only admin of Zanata project can upload the dictionaries for translation, for more questions please ask on IRC #aeolus.

Clone this wiki locally