Translator documentation: Difference between revisions

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
Line 201: Line 201:
tx -d push -s  # To push source file
tx -d push -s  # To push source file
</source>
</source>
<!-- INTEGRATION IS PART OF THE PROCESS USING TRANSIFEX AND TRANSLATORS DON'T HAVE TO DO ANYTHING IN ORDER TO DISTRIBUTE THEIR WORK
= [[File:Language.png]] Distribute or integrate your translation =
== Into official Dolibarr sources ==
The best thing after making a translation, is to include it on official version of Dolibarr.
If you made the translation using Transifex web interface, there is nothing to do. The Dolibarr development repository will be synchronized by released manager to include your changes.
If you have edited existing .lang files or if you have created new .lang files for a new language, you can:
* You can push changes/new files if you know how to use a GIT system. For this create an account on {{TemplateUrlSCM}}, 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 {{TemplateURLMLDev}}). 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.
== 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 {{TemplateURLMLDev}}).
User just has to unzip package into its dolibarr root directory to have language available.
-->


= [[File:Language.png]] Distribute or include your tanslation into core source =
= [[File:Language.png]] Distribute or include your tanslation into core source =

Revision as of 09:25, 9 October 2013

<keywords content="translation, documentation, translator, localize, localization, i18n, internationalization, language" />

Language.png 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 3 methods for translating Dolibarr (1 automatic: autotranslator, 2 manual: a completely manual method or transifex).

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 method using Transifex (see later).

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 (not recommended)

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.


Manual Translation using Transifex online service (recommended)

Transifex is a web application that provides an online platform for translation projects. It includes teams 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 but we will use the online hosted service.

Create transifex account and choose language

If you want to help translating Dolibarr in your own language, please refer to http://transifex.com/projects/p/dolibarr/ and see if language is already supported. If it exists (many teams are already working for the project), you can ask to join the team and start to translate right away; if there is not a team for your language, you should request a new translation team on Transifex. It can be done directly using transifex.com interface on the website.

Using the web interface (for translators)

If language is already available onto page http://transifex.com/projects/p/dolibarr/, just create an account and follow instruction of transifex web site to translate files. Note, that this web interface must not be used to translate the following languages:

  • en_US
  • fr_FR
  • es_ES
  • ca_ES

(this languages are still maintained using git).

Using TX command line client (for Dolibarr Category:Yoda team)

This describe how to use Transifex from command line. However, this is reserved to Dolibarr admin users to synchronize Transifex with Dolibarr main sources.

TX Client configuration

First install TX Client. With Debian/Ubuntu/Mint:

apt-get install python-pip
pip install transifex-client

Then you have to initialize your TX environment. This is done by running tx init into dolibarr project root directory.

cd git/dolibarr
tx init

Accept to overwrite config file. Keep default value for Transifex instance, then enter your Transifex login and password.

After this, a .transifexrc has been created into your HOME dir and a generic config file has been created as .tx/config in project's root. So your directory's contents will look like that:

.
|-- build
|-- build.xml
|-- ChangeLog
|-- COPYING
|-- COPYRIGHT
|-- dev
|-- doc
|-- .gitignore
|-- htdocs
|-- INSTALL
|-- pom.xml
|-- quickbuild.xml
|-- README
|-- README-FR
|-- README.md
|-- robots.txt
|-- scripts
|-- test
`-- .tx

The current config file can be downloaded from https://github.com/Dolibarr/dolibarr/tree/develop/.tx , put it into .tx directory, overwriting the one created by tx init

This project configuration file is used to store the project’s details and the file-to-resource mappings.

That is a sample of what the config file contains:

[main]
host = https://www.transifex.com

[dolibarr.admin]
file_filter = htdocs/langs/<lang>/admin.lang
source_file = htdocs/langs/en_US/admin.lang
source_lang = en_US
type = MOZILLAPROPERTIES

Here is an explanation of the sections and options used in the config file:

[main] section

In this section we have project-wide options, such as the default transifex host for all projects. These can be overriden by each resource, in case it is needed.

[dolibarr.resource]

source_lang: this is the source language of the resource.
source_file: this points to the source file directly.
file_filter: here we hold the expression used to identify translation files under the specific project. not mandatory
trans.<lang>: this is used for translation files that don’t follow a common naming schema and the file expression cannot be used to track them. not mandatory
host: in case the project doesn’t use the default Transifex server as specified in the [main] section, it can override it using this option. not mandatory

TX Client use

Some useful information on tx commands.

tx status

Show status of translations

tx push

Used to push changes from your computer to Transifex server
Additional options for the tx push command are:

-h - Shows the help screen for the command
-l <lang> - Specify which translations you want to push (defaults to all)
-r <resource> - Specify the resource for which you want to push the translations (defaults to all)
-f - Push source files without checking modification times
--skip - Don't stop on errors. Useful when pushing many files concurrently.
-s - Push the source file to the server
-t - Push the translation files to the server
--no-interactive - Don't require user input when forcing a push

tx pull

Used to pull changes from Transifex server to your computer
Additional options for the tx pull command are:

-h - Shows the help screen for the command
-l <lang> - Specify which translations you want to pull (defaults to all)
-r <resource> - Specify the resource for which you want to pull the translations (defaults to all)
-a - Fetch all translation files from server (even new ones)
-s - Force the fetching of the source file (default: False)
-f - Force download of translations files
--skip - Don't stop on errors. Useful when pushing many files concurrently.
--disable-overwrite - By default Transifex will fetch new translations files and replace existing ones. Use this flag if you want to disable this feature.
--minimum_perc=VALUE - Specify the minimum acceptable percentage of a translation in order to download it.

Examples

To pull translation files, you can use:

tx -d pull -l it_IT  # Get italian language only
tx -d pull -a   # Get all languages

To push source files, just type:

tx -d push -t -l it_IT [-r dolibarr.file]   # To push only a specific translation file
tx -d push -s  # To push source file

Language.png Distribute or include your tanslation into core source

Into official Dolibarr sources

The best thing to do after performing a translation, is included in the official version of Dolibarr.

If you have completed lang files already existing in Dolibarr but incomplete or if you have created new files lang for a new language, you can:

  • If the translation was done by using the Transifex system for languages ​​other than en_US, en_GB, es_ES ca_ES and (see above), there is nothing special to do. Your translation will be integrated by regular synchronization that occurs with the official Git sources (at least one per month).
  • If the translation was made directly to files for en_US, en_US, es_ES and ca_ES languages, it is possible to integrate if you know the GIT system. To do this, create an account on https://github.com/Dolibarr/dolibarr, fork the project, edit the relevant files and send a Pull Request.

Note: There are two reference language always complete:

  • French (Lang directory lang/fr_FR)
  • English (Lang directory lang/en_US)

It is possible to use either one or the other (which arranges) as a reference as 2 are updated. All other language files are likely to be incomplete.

As an extension

When you create a new language, if it is not integrated into Dolibarr, it can even be broadcast to all other users. You can make a package for distribution using the script 'build/makepack-dolibarrlang.pl or performing a manual zip so that you post on or dolistore.com on the mailing list for developers 'dolibarr-dev (Template:Registration on TemplateURLMLDev).

The file just needs to be made ​​in the unzipped directory Dolibarr for that language is available.

Language.png Translate documentation on wiki

The wiki is written in 3 languages: English, French and Spanish. If you want to enhance documentation on one of these languages, 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 Category:Page_waiting_for_translation.