Sep 29

Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by adding locale-specific components and translating text.

Due to the length of the words, the terms are frequently abbreviated to the numeronyms i18n (where 18 stands for the number of letters between the first i and last n in internationalization, a usage coined at DEC in the 1970s or 80s[1]) and L10n respectively. The capital L in L10n helps to distinguish it from the lowercase i in i18n.

Internationalization and localization instructions

Basic Terms

pot-file: Text file automatically generated with rake task (rake updatepo) or rgettext that shows all the original messages (msgid) inside the app code. Developers should generate this files and send them to translators as a template to write the po files (translated version of the pot file for a language).

po-file: Text file which is language-specific. It includes msgid(Original message) and msgstr(Translated message)

mo-file: Binary Files which are created from po-files with rake task (rake makemo) or rmsgfmt. The Ruby-GetText-Package library reads this compiled mo-files, not po-files.

File Maintenance

To do I18n maintenance, you need to install ruby-gettext-package

As it is not in the gem repository, you need to:
1) Download ruby-gettext-package- from here
2) Extract ruby-gettext-package-
3) Go to the extracted directory and run “sudo ruby setup.rb”

How to add a new language?:

1) create language directory inside “po” folder (eg: es/)
2) Go inside new language folder and run: msginit -i ../ur_application_name.pot -o ur_application_name.po

How to update po files (when new keys are added or modified)?:
1) Go to app folder and run: rake updatepo

To recompile files (when you get new/modifed po files translated)
1) Go to app folder and run: rake makemo

How to add i18n to a Page?


Basics

If you want to translate a text. Eg. “This text” You need to simple call _(). E.g _(“This text”).

The key will be added to the po file and someone will translate it later. If the key is already in the po file (and compiled in the mo file) it will appear translated. You should choose keys that make sense and that might be reusable. Try not to pick very long texts as keys.

Model: All field names are automatically added to the po file from the database (whith the rake task). If you need to define constants or translate new error messages, you can use the N_() function. For more information, check: http://www.yotabanana.com/hiki/ruby-gettext-howto-rails.html

written by admin


Leave a Reply