Wiki source for HowToTranslate


Show raw source

=====webERP Translations=====

webERP can be translated to any language so that the entire web-interface is displayed in the language of any user. The system can display different languages for different users - all at the same time - depending on the setting of the language in the individual users' settings.

Following resolution of a long standing problem by Javier - producing PDF reports that were of acceptable size and at the same time using the utf-8 character set. (The solution was to make use of Adobe CID fonts - this needs the user to use the adobe acrobat reader if using non-English pdfs) - translations all use utf-8 character sets. webERP is now completely utf-8 for all languages. This requires that the necessary utf-8 locales are installed on your web-sever.

====Procedure====

1. It is wise to see if a translation is being worked on, so ask the question on the developers list
Join the mailing list at:

http://lists.sourceforge.net/lists/listinfo/web-erp-developers

Copies of all current translations are now included with the webERP archive so if there is any work started on your language then it will be included with the latest release. However, someone may already have started the translation after the last release, so it is wise to advise the translation list.

2. Obtain the latest messages.pot file to edit manually. There are tools available to edit this file quite efficiently search google for poedit

The latest messages.pot file is normally in the latest distribution, under webERP/locale/en_GB.utf8/LC_MESSAGES/messages.pot alternatively it can be downloaded from:

[[https://sourceforge.net/p/web-erp/code/HEAD/tree/trunk/locale/en_GB.utf8/LC_MESSAGES/messages.pot
The source code SVN repository]]

Make a copy and edit the file provided entering the translations for the strings labelled msgid in the string labelled msgstr. Although every attempt has been made to avoid it, watch out for html strings embedded inside the strings the html will also be required in the translated string. Please complete the translation file header information - with your details so that you are accorded proper recognition for your contribution.

A new folder under webERP/locale/ needs to be created with the locale abbreviation for your language - note that webERP requires utf-8 locales - some examples:

fr_FR.utf8 - French
en_US.utf8 - English US
de_DE.utf8 - German

say you are creating a German translation you need to create the folder

webERP/locale/de_DE.utf8

and the folder below this called LC_MESSAGES

webERP/locale/de_DE.utf8/LC_MESSAGES

The edited messages.po file needs to be saved under this folder.
With the new messages.po under webERP/locale/de_DE.utf8/LC_MESSAGES you need to run the gettext utility msgfmt that "compiles" the messages.po file into a messages.mo file -from the command line:

# cd webERP/locale/de_DE.utf8/LC_MESSAGES
#msgfmt messages.po

Return the messages.po file containing your translations to info@weberp.org

Note that all these translations currently already exist so you will see these directories and files already in the distribution.

The translations can be selected in the main system by clicking on the user name - a list of the languages available will be shown with their locale abbreviations available for selection. Select your new language folder then click on the enter button. The interface should now appear with the translations you entered in your messages.po

An archive of the new language directory and instructions on how to use it will be emailed for your use and a distribution of the language pack set up on sourceforge by the project administrator.


Language codes must follow the standard format for locales, 2 lower case characters for the language and then an underscore then a further 2 characters in upper case representing the country - the utf-8 locale for the country normally has .utf8 appended eg:

en_GB.utf8 - english underscore Great Britain - using the utf-8 character set
en_US.utf8 - english underscore United States
en_AU.utf8 - english underscore Australia

For the translation to be used the locale code must be recognised by the machine (you can check the locales defined on a *nix machine by typing locale -a at the # prompt).

For the language to be available for selection by users from the web-interface, the file includes/LanguagesArray.php needs to have the new translation added to it. This file contains entries as follows:

$LanguagesArray['de_DE.utf8']['LanguageName'] = _('German');
$LanguagesArray['de_DE.utf8']['WindowsLocale'] = 'german';
$LanguagesArray['de_DE.utf8']['DecimalPoint'] = ',';
$LanguagesArray['de_DE.utf8']['ThousandsSeparator'] = '.';

Of course these entries are for the German translation. These entries define the Language name that appears in the interface, the windows locale name - so that the translation also works with windows, the character to be used as the decimal point and the thousands separator for users of this language.

It is important not to enter the " character in any translations - since this is used by gettext to quote the strings.

It is recommended that translations start with the index.php module since this main menu is the most visible of all pages.

That's it! However, for the more curious and technically minded more detail is provided below on the mechanics of the gettext system.


====Technical Overview====

**How is it Done**

webERP uses the GNU gettext package for language translations. PHP must be compiled with gettext functions to enable multi-language translations. However, it will produce english if the PHP interpreter does not have the gettext functions compiled in to the server.

The gettext translation files are held in the locale directory, under this directory there are sub-directories for each locale, a two character code representing the language to be used. eg en for English, it for Italian etc. New directories will be made up on request if a translator wishes to have a local version for their language. Under the locale, two character abbreviation code directory there is a further sub-directory called LC_MESSAGES - this is where the translation files exist. There are two files in each of these directories:

1. messages.po this file contains all the strings to be translated. This is the only file of concern for translators
2. messages.mo this is a binary machine searchable tranlation file used by gettext. The .mo file is produced by a gettext utility using the .po. The effort is needed to get the .po file translated - the .mo file is easily created by the project admin.

Any text editor can be used to edit the .po file (GNU Emacs contains specific functionality for editing .po files there is a special PO-Mode - there is also an editor called poedit which has some useful tools for administering gettext translations)


**Understanding the messages.po File**

The translation is performed by translating the strings in the messages.po file into the other language. It is important to work on the most recent messages.po file from the locale/en_GB.utf8/LC_MESSAGES/ directory in the SVN. This can be downloaded directly [[http://web-erp.svn.sourceforge.net/viewvc/web-erp/trunk/locale/en_GB.utf8/LC_MESSAGES/messages.pot here]].

The messages.po is made up of sections

eg. for a French translation file

#: AccountGroups.php:8 index.php:890
msgid "An example string in English that needs to be translated"
msgstr "Une corde d'exemple dans le ce anglais doit A?tre traduite "

the line #: AccountGroups.php:8 index.php:890

means that the string following is used in the AccountGroups.php script on line 8 and the index.php script on line 890. It could be useful to understand the context of where the script is used. Strings that are used several times throughout the application only need to be translated once. In some cases the #: line showing where the string is used can be quite an extensive list of scripts.

msgid "An example string in English that needs to be translated"

this line is the english string which is to be substituted by the text in msgstr. If the value of msgstr is empty - "". gettext will return the english string.

The effort of the translation is to edit the messages.po file and enter the language translation within the inverted commas of the msgstr.


The .po File Header

The .po file starts with some initial comments which should also be completed

"SOME DESCRIPTIVE TITLE", - should be replaced with webERP - LANGUAGE Translation File - where LANGUAGE is the language being translated into
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. - should be your name and email address - with the year of the work being done


Project-Id-Version
Should be webERP - version number

PO-Revision-Date
This is the date of your last entries in the file

Last-Translator
This is your name and email address for users of this language to contact should some translations be unclear

Content-Type
Replace `CHARSET' with utf-8 - all translations of webERP must use utf-8

Historically, due to the fact that the utf-8 contains so many characters, fonts that can display them all are necessarily very large. Whilst it is possible to create utf-8 fonts to work with the fpdf class that creates the pdf reports in webERP, the file size of such reports makes them inpractical to use over dialup connections and is therefore webERP could not use utf-8. Javier de Lorenzo-Cáceres pioneered the use of Adobe CID fonts in webERP with Nicola Asuni's TCPDF PDF creation class itself a development of Olivier Plathey's FPDF. Javier has written [[http://www.weberp.org/Utf8Pdf some technical description]] of how he was able to achieve this.

The character encoding name - always utf-8 - can be written in either upper or lower case. Usually upper case is preferred.

Content-Transfer-Encoding
Set this to 8bit


Administration

Once this has been completed the file must be returned to the project administrator: submissions@weberp.org for the .mo file to be created. The new directory will be returned in a zip file for extraction from the web-erp directory. The language will then be added to the webERP system for the benefit of other users as well.

Upon logging into the system each time the system sets the language used by looking up the user information to see what language they have set. The user can change which language is set by clicking on their user name at the top left which brings up User Settings. Changing the language setting will activate the new language right away upon saving the change. Only languages for which there is a directory under the locale directory can be selected by the user.


Other Resources

The GNU gettext manual:

http://www.gnu.org/software/gettext/manual/html_chapter/gettext_toc.html#SEC_Contents

Notes on GetText

[[Internationalization Internationalization]]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki