Translator documentation
From Dolibarr Wiki
Contents
|
Translate Dolibarr into another language
Dolibarr language files are translated in several languages. French and English are by default always complete. Other languages depend on contributions. This tutorial can help you to complete a translation that does not exists or is not correct for another language.
There are 4 methods for translating Dolibarr (1 automatic: autotranslator, 3 manual: phpLangEditor, iniTranslation and the completely manual method). They are in order of preference:
Automatic Translation with autotranslator.php tool
- Translator OS: All
- Tool: autotranslator.php provided with Dolibarr in directory dev/translation.
This method is recommended when starting translation for a language not already initialized. If there is already a translation available but you need to add missing key or correct errors, try to use next method.
To make or update all files of a language code, just run the script:
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY
For example :
php autotranslator.php en_US pt_PT GOOGLEAPIKEY
to translate into Portuguese (pt_PT) using English (en_US) files.
All non existing files will be created, all existing files will be updated. The tool use Google translation service to find the translation value of a string, so a working Internet connection is required from station running the script. Also a GOOGLEAPIKEY is required and Google charges a fee for using this service (20 euros / 1 000 000 of translated chars). Your PHP must also have permissions to write into htdocs/langs directory and must have curl functions available.
Manual Translation with the Firefox plugin phpLangEditor
Follow these steps to translate using the Firefox plugin:
- Install Firefox and install plugin phpLangEditor (Media:PhpLangEditor254.xpi)
- A further step is required to complete the installation. Type into URL field, the text about:config then in the Filter field, enter phplangeditor. Double click on the line phpLangEditor.file.typeOfLangExt and put ini in field. phpLangEditor is now ready to translate Dolibarr.
- From Firefox, open phpLangEditor by selecting the menu Tools -> PHP lang editor.
- Click on "Open reference file" and choose your file. Lang original (eg in your Dolibarr, htdocs / lang / en_US / bills.lang
- Click 'Open file translation and select the file containing the translation, if a file exists (eg htdocs / lang / es_ES / bills.lang).
- You can choose to display all the words to translate the words or only non-translated. Click on the term in the left column to translate it into the box below. You can also use keyboard shortcuts such as CTRL + N to move to the next
- Save the file once the translation is finished.
- Edit the file with a text editor to remove or correct the first comment line. Indeed, with phpLangEditor, it is not possible to translate the lines Discussed (starting with #), the file contains translated once recorded the comment line of the source file. A small manual editing is needed to correct or delete this line, although this does not adversely affect the proper functioning of the new file. Lang.
Manual Translation with iniTranslator
- Translator OS: Windows
- Tool: iniTranslator (Windows).
Follow these steps to translate using iniTranslator :
- Run your application translation will ask the template file (For example, under iniTranslator, do File - Open Original). Choose the source model in the directory htdocs / lang / en_US or htdocs / lang / en_US, which are up to date.
- Then choose the destination file may, in the directory htdocs / lang / xx_XX or xx is the language code to translate.
- Your tools will display the files 2 face to face with the missing strings to translate.
- Complete files.
- Save the new destination file.
Attention, iniTranslator has a serious defect. It does not retain the original order of the parameters and the generated file sorting alphabetically rather than keys in the order of the source file. In addition, areas comments source files are not reflected in the destination file translated.
Manual translation
To translate Dolibarr into another language, go to the langs directory and create a folder/directory named with the code language to translate (follow the existing format, for example en_US, en_GB, es_ES, de_DE, etc...). Then copy the files from an existing language directory (for example en_US/main.lang, en_GB/bills.lang), into the new language directory that you have just created.
These files have the format of key/value pairs in each line like the followings:
Code1 = translate phrase 1 Code2 = translate phrase 2 ... Coden = translate phrase n
Translate the phrases (the value portion of the key/value pairs) on right side of the "=" as seen above, the code (the key portion) on left side of "=" should remain unchanged. It is possible to translate the files one by one, without bringing them all at once. If a file has not been translated into the new language, Dolibarr uses English.
To have a localised (translated) string into the PHP code, all you have to do is load the language file and use the method to get the translated value, like this:
$langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX print $langs->trans("CodeX")
An entry type;
CodeX = phrase X
must be present or added to the myfile.lang file.
Translate online using Transifex
Transifex is an web application that provides an online platform for translation projects. It includes team and discussion tools, translation memory, glossary, proofreading and a lot of other features. It is quite easy to use and all translations can be uploaded or downloaded through the web interface or using their TX client in a terminal. Transifex is an open source project and the "community edition" can be freely downloaded and installed. There is also an hosted version which can be freely used by free and open source projects.
Translation teams
Using the web interface
TX Client configuration and use
Integrate its translation into Dolibarr
If you have completed existing but incomplete .lang files or if you have created new .lang files for a new language, you can:
- You can upload changes/new files if you know how to use a GIT system. For this create an account on http://www.github.com, fork Dolibarr project, make your change then send a Pull Request.
- Or just send your files by mail attachment to the list: dolibarr-dev@nongnu.org (subscription on page https://savannah.nongnu.org/mail/?group=dolibarr). A developer will add it for you into project.
Note: There are two master/reference languages, both of them are always upto date and complete:
- English (Language files are in the directory langs/en_US)
- French (Language files are in the directory langs/fr_FR)
You can use either of the two as reference because both are up to date. All other language files are likely to be incomplete.
Distribute your translation
Into official Dolibarr sources
The best thing after making a translation, is to include it on official version of Dolibarr. For this, just read previous chapter.
As a separate addon file
When you create a new language, if it is not integrated into Dolibarr, it can still be spread to others. You can build a package to distribute using the script build/makepack-dolibarrlang.pl but you can also make a zip by your own to send it on dolistore.com or on developer mailing-list dolibarr-dev (subscription on page https://savannah.nongnu.org/mail/?group=dolibarr).
User just has to unzip package into its dolibarr root directory to have language available.
Translate documentation on wiki
The wiki is written in 3 languages: English, French and Spanish. If you want to enhance documentation on one of this language, all you have to do is to create an account on this wiki. Then, you can edit existing pages to correct a bad translation or translate pages waiting for translation on page Category:Page_waiting_for_translation.
Ask to contact@dolibarr.org to request an account to contribute to this documentation
