Skip to content

Localization and Locale

mattpascoe edited this page Nov 29, 2013 · 2 revisions

An attempt at adding localization is being made. Here are some notes related to what is being done.

System setup

On your server that you have installed ONA to you must have all languages you wish to support properly configured in your system locale. This is likely done many ways depending on your distro. Here is how I view and set up things on Ubuntu.

  • List what is available:
vagrant@precise64:~$ locale -a
C
C.UTF-8
de_AT.utf8
de_BE.utf8
de_CH.utf8
de_DE
de_DE.iso88591
de_DE.utf8
de_LI.utf8
de_LU.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
fr_BE.utf8
fr_CA.utf8
fr_CH.utf8
fr_FR
fr_FR.iso88591
fr_FR.utf8
fr_LU.utf8
POSIX
  • Add a new supported language, in this example, Japanese:
vagrant@precise64:~$ sudo locale-gen ja
Generating locales...
  ja_JP.UTF-8... done
Generation complete.
  • reconfigure the system locale:
  vagrant@precise64:~$ sudo dpkg-reconfigure locales
  Generating locales...
    de_AT.UTF-8... done
    de_BE.UTF-8... done
    de_CH.UTF-8... done
    de_DE.ISO-8859-1... done
  ...
  ...
    fr_FR.ISO-8859-1... done
    fr_FR.UTF-8... done
    fr_LU.UTF-8... done
    ja_JP.UTF-8... up-to-date
  Generation complete.
  • Now you should see a Japanese entry in the output of locale -a
  • restart apache using service apache2 restart or similar command

This should make your language available to ONA.

Installing a new language for ONA

At the moment languages are still in development and the process for installing them may change. For now you should be able to download a language and place it into /opt/ona/www/Locale/<LANG> and it should then be active. This assumes you have added it to your system as outlined above.

Developers

The process and practices of adding new languages is still being developed. Once the pages have been updated to use the gettext() functions it should be as simple as using xgettext to extract out a new messages.po file that can then be translated. More to come on this.....

Here is an example of working with the messages.po file

  • Change to the language directory you are working on cd /data/code/ona/www/Locale/fr_FR/LC_MESSAGES
  • ensure we have an updated base messages copy from source. This uses en_US as the default dir to place this file into:
xgettext -o /data/code/ona/www/Locale/en_US/LC_MESSAGES/base-messages.po /data/code/ona/www/include/html_desktop.inc.php; sed --in-place /data/code/ona/www/Locale/en_US/LC_MESSAGES/base-messages.po --expression=s/CHARSET/UTF-8/
  • Merge our local copy with the base as we continue to add new references. This should keep current updates in line with new references added to the code. It then creates the compiled .mo file.
msgmerge -o messages.po messages.po /data/code/ona/www/Locale/en_US/LC_MESSAGES/base-messages.po ; msgfmt messages.po -o messages.mo
  • Make changes to the messages.po file
  • run msgfmt messages.po -o messages.mo to make those changes active.
  • dont forget to restart apache after you've updated the .mo file