Sugar i18n

From OLPC
Revision as of 16:05, 25 May 2007 by Xavi (talk | contribs) (tweaking... possibly merge)
Jump to navigation Jump to search
Merge-arrows.gif
It has been suggested that this article or section be merged with Customizing NAND images. (Discuss)

This is a tutorial (recovered from an IRC session in the #olpc-peru channel, on how to enable Sugar in Spanish. Other locales/languages may adapt accordingly.

WARNING
What follows is more an empiric report instead of a well thought out, fact-based, guide. If anybody can give more 'academic weight' to the subject by means of annotations or corrections, please do so.

Verify i18n

Most of the internaliz/sation (aka i18n) present in the activities or environment relies on three things:

  1. the LANG and LANGUAGES environment variables;
  2. the different locales in the system; and
  3. the existance of the appropriate 'catalogs' of localized strings in each locale (.mo files).
LANG and LANGUAGES
serve to declare the base LANGuage, and the default sequence of linguistic preferences when trying to chose one that is not available. They are defined in the /etc/sysconfig/i18n
 File: /etc/sysconfig/i18n

LANG=es_AR

LANGUAGE=es_AR.UTF-8:es_AR:es.UTF-8:es:en_US.UTF-8:en
Locales & string catalogs
are basically the definition of how a particular location represents some aspects (ie: decimal and thousands separators, time formats, etc.) Each locale has an LC_MESSAGES sub-directory where catalogs of strings (.mo files) are stored by applications.
 /usr/share/locale
                  /es_AR.UTF-8/LC_MESSAGES
                  /es_AR/LC_MESSAGES
                  /es.UTF-8/LC_MESSAGES
                  /es/LC_MESSAGES
                  /en_US.UTF-8/LC_MESSAGES
                  /en/LC_MESSAGES
A particular application or activity may have a set of (i18n) strings for each locale in a .mo file, or most likely a set of standard ones in select locales. What is important, is to have a sugar.mo in at least your base language (ie: .../locale/es/LC_MESSAGES/sugar.mo independently if your locale is Argentina, Peru or Uruguay in the case of Spanish. Similarly, for other languages. If the system can't find the right locale, it will default to the native language of the application—most probably English.
Activity Bundles have their own locale subdirectory structure where they store their string catalogs (.mo files).
NOTE: given that .PO files also store language info, the above relationship between .mo (a derivative of a .po files) and the actual directory needs to be verified!

So in order to have Sugar in your own language, you must have a .mo (derived from an appropriate .po file) in a corresponding .../locale/language_pref/LC_MESSAGES directory.

In order to verify this you can do the following:

echo LANG         # to see what is the currently default language of your system
echo LANGUAGES    # to see the sequence of languages the system fallbacks to

And verify in which of those locales a sugar.mo file is found. If you fail to have the appropriate combination, then you should try to set it up by following the instructions below.

Sugar in your language

Obtaining the .po

In order to generate the corresponding .mo file, we must have a .po for the target language (ie: es.po). You can find the currently available file in the git po tree (currently it has the es.po, ha.po, ig.po, it.po, and yo.po files).

If you don't find the .po in your language you can always grab an existing one, copy it to an appropriate name (ie: ur.po) and translate it into said language (in the example ur=urdu).

Making the .mo

In order to generate a particular .mo from its .po you must have access to gettext, which if you don't have in your system you can install it by doing

yum install gettext         # for Red Hat / Fedora systems
apt-get install gettext     # for Ubuntu / Debian systems

msgfmt es.po -o es.mo       # to create the given .mo
cp es.mo /usr/share/locale/es.UTF-8/LC_MESSAGES/sugar.mo

Keyboard in your language

What good is seeing the interface in a particular language if your keyboard is in another? Here's how you get your keyboard in your language. (extracted from Customizing NAND images).

 File: /etc/X11/xorg.conf
Section "InputDevice"
Identifier "Keyboard1"
...
Option "XkbLayout" "en"
Option "XkbOptions" "olpc"
EndSection

You should modify the "XkbLayout" "en" to whatever layout you want (ie: es, pt, ...). In order to enable the language switch (Key arabic.jpg or Key thai.jpg) you should set "XkbLayout" "en,ara" or other combinations (ie: "en,th"; "en,ur"; etc.) and Option "XkbOptions" "olpc" to "olpc,olpc2"

 File: /etc/X11/xorg.conf
Section "InputDevice"
Identifier "Keyboard1"
...
Option "XkbLayout" "en,th"
Option "XkbOptions" "olpc,olpc2"
EndSection

After saving the changes, and in order to enable them, you must either reboot the machine, or issue the following commands:

/sbin/telinit 3
/sbin/telinit 5






what follows is a dump/resume of the chat session... will translate and format
  • entrar en consola (o vía ssh) y fijarse si existe el siguiente archivo:
    /usr/share/locale/es/LC_MESSAGES/sugar.mo
    (pueden existir otros como aspell.mo y hal.mo)
  • el es.PO esta en:
    HTML
    UTF-8
    other - http://gnrfan.org/files/olpc/l10n/es.po.gz
    wget -c http://gnrfan.org/files/olpc/l10n/es.po.gz
    gunzip es.po.gz
    si tienen un .POT (Portable Object *Template*) y quieren crear un .PO para nu nuevo idioma se lo renombra:
    • cp sugar.pot es.po
  • proceder a instalar gettext segun la distro: (por lo menos en el build 406 no está)
    • yum install gettext # Red Hat
    • apt-get install gettext # Ubuntu / Debian
  • crear el .MO
    msgfmt es.po -o es.mo
  • asegurarse que el LANG esté bien configurado (fundamental el .UTF-8)
    es_AR.UTF-8
  • instalar el .MO
    mkdir -p /usr/share/locale/es.UTF-8/LC_MESSAGES
    cp es.mo /usr/share/locale/es.UTF-8/LC_MESSAGES/sugar.mo
  • configurar la variable de entorno en /etc/sysconfig/i18n debe decir
    LANG="es.UTF-8"
    la variable LANGUAGE va poniendo lenguajes por prioridad
    LANGUAGE="es_PE.UTF-8:es_ES.UTF-8:es.UTF-8:es_PE:es_UE:es:en_US.UTF-8:en"
  • reboot!