Translator documentation: Difference between revisions

No edit summary
 
(70 intermediate revisions by 13 users not shown)
Line 1: Line 1:
<keywords content="translation, documentation, translator, localize, localization, i18n, internationalization, language" />
<!-- BEGIN origin interlang links -->
<!-- You can edit this section but do NOT remove these comments
    Links below will be automatically replicated on translated pages by PolyglotBot -->
[[fr:Documentation_traducteur]]
[[es:Documentación_traductores]]
[[de:Dokumentation_Uebersetzung]]
[[zh:翻译文档]]
<!-- END interlang links -->
{{#metamaster:keywords|translation, documentation, translator, localize, localization, i18n, l18n, internationalization, language}}


= [[File:Language.png]] Translate Dolibarr into another language =
=[[File:Language.png]] Translate Dolibarr Application into your language=


Dolibarr language files are translated in several languages.
Dolibarr language files are already 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.
English is the default and always complete. Other languages depend on contributions. This tutorial can help you complete a translation for a language not yet available or somehow incorrect.
<!-- TRANSIFEX IS THE STANDARD NOW, WHAT TO DO WITH NOTES ABOUT ALTERNATIVE METHODS?
Dolibarr can be translated by three different means:
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 ==
#Manually using Transifex (Official and recommended method).
#Manually editing language files
#Completely automatic: autotranslator


* Translator OS: All
==Manual Translation using Transifex online service (recommended)==
* 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:
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.
<source lang="bash">
It is quite easy to use and all translations can be uploaded and downloaded through the web interface or using their TX client from a terminal.
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY
Transifex is an open source project and the "community edition" can be freely downloaded and installed, but we will use the online hosted service.
</source>
For example :
<source lang="bash">
php autotranslator.php en_US pt_PT GOOGLEAPIKEY
</source>
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 [http://translate.google.com 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 ==
 
* Translator OS: All
* Tool: phpLangEditor (plugin for Firefox) [[File:PhpLangEditor.jpg|40px]]


Follow these steps to translate using the Firefox plugin:  
===Using the web interface (for translators)===
If you want to help to translate Dolibarr in your own language, check the project's page at https://app.transifex.com/dolibarr-association/dolibarr/dashboard/


# Install Firefox and install plugin phpLangEditor ([[Media:PhpLangEditor254.xpi]])
You can then register an account and request joining the project team for the language(s) you're targeting. A manager will have to accept your request, so please be patient.
# 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 ==
Once accepted, you can start translating right away.


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.
For more information, please check Transifex "Getting Started" introduction at http://docs.transifex.com/introduction/translators/ and the web editor tutorial at http://docs.transifex.com/tutorials/txeditor/


These files have the format of key/value pairs in each line like the followings:
''' Note about en_US '''


<source lang="ini">
The web interface can not be used to translate the en_US language which is source.
Code1 = translate phrase 1
Code2 = translate phrase 2
...
Coden = translate phrase n
</source>


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.
Any change for en_US language must be done in Dolibarr source code and submitted using a Pull Request on our GitHub repository.


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:
===Using TX command line client (for Dolibarr [[:Category:Yoda]] team)===
This describes how to use Transifex from the command line. However, this is reserved to Dolibarr admin users to synchronize Transifex with Dolibarr main sources.


<source lang="php">
More information can also be found on the [http://docs.transifex.com/developer/client/ Transifex Official documentation]
$langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX 
 
print $langs->trans("CodeX")
</source>
 
An entry type;
 
<source lang="ini">
CodeX = phrase X
</source>
 
must be present or added to the myfile.lang file.
-->
 
== Manual Translation using Transifex online service==
 
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====
====TX Client configuration====
First install TX Client.
First install TX Client.
With Debian/Ubuntu/Mint:
With Debian/Ubuntu/Mint:
<source lang="bash">
<syntaxhighlight lang="bash">
apt-get install python-pip
apt-get install python-pip
pip install transifex-client
pip install transifex-client
</source>
</syntaxhighlight>
Then you have to initialize your TX environment. This is done by running '''tx init''' into dolibarr project root directory.
Then you have to initialize your TX environment. This is done by running '''tx init''' into dolibarr project root directory.
<source lang="bash">
<syntaxhighlight lang="bash">
cd git/dolibarr
cd git/dolibarr
tx init
tx init
</source>
</syntaxhighlight>
Accept to overwrite config file. Keep default value for Transifex instance, then enter your Transifex login and password.
Accept to overwrite config file. Keep default value for Transifex instance, then enter your Transifex login and password.


Line 136: Line 84:
</pre></code>
</pre></code>


The current config file can be downloaded from https://github.com/Dolibarr/dolibarr , put it into .tx directory, overwriting the one created by '''tx init'''
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.
This project configuration file is used to store the project’s details and the file-to-resource mappings.
Line 142: Line 90:
That is a sample of what the config file contains:
That is a sample of what the config file contains:


<source lang="ini">
<syntaxhighlight lang="ini">
[main]
[main]
host = https://www.transifex.com
host = https://www.transifex.com
lang_map = uz: uz_UZ


[dolibarr.admin]
[dolibarr.admin]
Line 151: Line 100:
source_lang = en_US
source_lang = en_US
type = MOZILLAPROPERTIES
type = MOZILLAPROPERTIES
</source>
</syntaxhighlight>


Here is an explanation of the sections and options used in the config file:
Here is an explanation of the sections and options used in the config file:
Line 157: Line 106:
<nowiki>[main] section</nowiki>
<nowiki>[main] section</nowiki>


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.
In this section, we have project-wide options, such as the default transifex host for all projects. These can be overridden by each resource, in case it is needed.


<nowiki>[dolibarr.resource]</nowiki>
<nowiki>[dolibarr.resource]</nowiki>


source_lang: this is the source language of the resource.<br/>
source_lang: this is the source language of the resource.<br />
source_file: this points to the source file directly.<br/>
source_file: this points to the source file directly.<br />
file_filter: here we hold the expression used to identify translation files under the specific project. ''not mandatory''<br/>
file_filter: here we hold the expression used to identify translation files under the specific project. ''not mandatory''<br />
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''<br/>
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''<br />
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''<br/>
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''<br />


====TX Client use====
====TX Client use====
Line 190: Line 139:
'''tx pull'''
'''tx pull'''


Used to pull changes from Transifex server to your computer<br/>
Used to pull changes from Transifex server to your computer<br />
Additional options for the tx pull command are:
Additional options for the tx pull command are:
<code><pre>
<code><pre>
Line 196: Line 145:
-l <lang> - Specify which translations you want to pull (defaults to all)
-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)
-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)
-a - Fetch all translation files from the server (even new ones)
-s - Force the fetching of the source file (default: False)
-s - Force the fetching of the source file (default: False)
-f - Force download of translations files
-f - Force download of translations files
Line 207: Line 156:
To pull translation files, you can use:
To pull translation files, you can use:


<source lang="bash">
<syntaxhighlight lang="bash">
tx -d pull -l it_IT  # Get italian language only
tx -d pull -l it_IT  # Get italian language only
tx -d pull -a  # Get all languages
tx -d pull -a  # Get all languages
</source>
</syntaxhighlight>


To push source files, just type:
To push source files, just type:


<source lang="bash">
<syntaxhighlight lang="bash">
tx -d push -t -l it_IT [-r dolibarr.file]  # To push only a specific translation file
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
tx -d push -s  # To push source file
</source>
</syntaxhighlight>
 
===Other questions on transifex process===
This is short questions and answers you may also ask about transifex translation process:
 
1) Is the sync done on a regular time interval?
 
No. It is done where there is enough translation submitted. It is also done on a beta branch just before creating the final release package.
2) Are all the translations synced to git or only the reviewed translations ? Do I need to review before sync is done?
 
When a Sync is done, transifex files overwrites files into git, but only if there is at least on record modified for the file.
You don't have to make a review before sync is done. Making review is above all to know which lines were manually reviewed and which one was initially translated using a robot. The sync always take the last translated version, even if the new translation was not reviewed.
3) In which Dolibarr releases will translations be available? Are Transifex translations also synced to maintenance releases?
 
Sync is always done on develop and/or beta.
So Transifex changes appear in all versions whose branch is created after the Transifex change (a sync is always done before creating a new branch). Once a branch is created, the new changes into Transifex will be available only for the next branch. The reason for this is that we do not manage branch/versions on Transifex (not yet).
 
==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:
 
<syntaxhighlight lang="ini">
Code1 = translate phrase 1
Code2 = translate phrase 2
...
Coden = translate phrase n
</syntaxhighlight>


= [[File:Language.png]] Distribute or integrate your translation =
Translate the phrases (the value portion of the key/value pairs) on the right side of the "=" as seen above, the code (the key portion) on the 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.


== Into official Dolibarr sources ==
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:
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.
<syntaxhighlight lang="PHP">
$langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX 


If you have edited existing .lang files or if you have created new .lang files for a new language, you can:
print $langs->trans("CodeX")
</syntaxhighlight>


* 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.
An entry type;
* 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.


<syntaxhighlight lang="ini">
CodeX = phrase X
</syntaxhighlight>


Note: There are two master/reference languages, both of them are always upto date and complete:
must be present or added to the myfile.lang file.


* 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.
==Automatic Translation with autotranslator.php tool==


== As a separate addon file ==
*Translator OS: All
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}}).
*Tool: '''autotranslator.php''' provided with Dolibarr in directory '''dev/translation'''.


User just has to unzip package into its dolibarr root directory to have language available.
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 a missing key or correct errors, try to use method using Transifex (see later).


= [[File:Language.png]] Translate documentation on wiki =
To make or update all files of a language code, just run the script:
The wiki is written in 3 languages: English, French and Spanish.
<syntaxhighlight lang="bash">
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY
</syntaxhighlight>
For example<span> </span>:
<syntaxhighlight lang="bash">
php autotranslator.php en_US pt_PT GOOGLEAPIKEY
</syntaxhighlight>
to translate into Portuguese (pt_PT) using English (en_US) files.
 
All nonexisting files will be created, all existing files will be updated.
The tool use [http://translate.google.com 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.
 
=[[File:Language.png]] Distribute or include your translation into core source=
 
Once you start translating, it's a smart decision to share it, so it can be included in the official code of Dolibarr.
If you keep it for you, others will not be able to improve it when new terms are added or previous terms are modified, and you will still have to manage the translation on your own.
 
If you translated through the Transifex system, there's nothing to be done. Your translation will be included in the next version of Dolibarr. No additional work! In technical terms, the translation will be exported from Transifex and imported into Dolibarr by our developers, at least once every month.
 
If, however, you translated directly in Dolibarr files, then you will first have to transfer those translations to Transifex before they can be included. So, really, you should start translating into Transifex.
If you send us your translation through a Pull Request on Github, sadly, it will be overwritten by the next import from Transifex, so it would be very short-lived.
 
Note:
 
The reference language is en_US and is always complete. You can find it in the htdocs/langs/en_US/ folder. All other language files are likely to be slightly or highly incomplete, depending on the language.
 
If you are developing a new module, you are likely going to need the addition of new language variables. This is done exclusively through the update of the en_US language (htdocs/langs/en_US/ folder). Just modify these files to add the variable you need and send the resulting folder as part of your Pull Request. Refer to the developer documentation to learn how to contribute code (you will need an account on {{TemplateUrlSCM}}.
 
=[[File: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.
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]].
Then, you can edit existing pages to correct a bad translation or translate pages waiting for translation [[:Category:Page_waiting_for_translation]].
<br />
===How to translate an existing page ?===
====Create a new page for the translated version.====
Start by creating a new page for the translated version. To do this, you can access an non existant URL<span> </span>: for example [[Translator documentation|<code>https://wiki.dolibarr.org/index.php/Ma_nouvelle_page_en_français</code>]]
The chosen title for the translated version of the page should be the translation of the title of the original English page.

Latest revision as of 08:47, 17 April 2026


Language.png Translate Dolibarr Application into your language

Dolibarr language files are already translated in several languages. English is the default and always complete. Other languages depend on contributions. This tutorial can help you complete a translation for a language not yet available or somehow incorrect. Dolibarr can be translated by three different means:

  1. Manually using Transifex (Official and recommended method).
  2. Manually editing language files
  3. Completely automatic: autotranslator

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 and downloaded through the web interface or using their TX client from 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.

Using the web interface (for translators)

If you want to help to translate Dolibarr in your own language, check the project's page at https://app.transifex.com/dolibarr-association/dolibarr/dashboard/

You can then register an account and request joining the project team for the language(s) you're targeting. A manager will have to accept your request, so please be patient.

Once accepted, you can start translating right away.

For more information, please check Transifex "Getting Started" introduction at http://docs.transifex.com/introduction/translators/ and the web editor tutorial at http://docs.transifex.com/tutorials/txeditor/

Note about en_US

The web interface can not be used to translate the en_US language which is source.

Any change for en_US language must be done in Dolibarr source code and submitted using a Pull Request on our GitHub repository.

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

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

More information can also be found on the Transifex Official documentation

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
lang_map = uz: uz_UZ

[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 overridden 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 the 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

Other questions on transifex process

This is short questions and answers you may also ask about transifex translation process:

1) Is the sync done on a regular time interval?

No. It is done where there is enough translation submitted. It is also done on a beta branch just before creating the final release package.

2) Are all the translations synced to git or only the reviewed translations ? Do I need to review before sync is done?

When a Sync is done, transifex files overwrites files into git, but only if there is at least on record modified for the file. You don't have to make a review before sync is done. Making review is above all to know which lines were manually reviewed and which one was initially translated using a robot. The sync always take the last translated version, even if the new translation was not reviewed.

3) In which Dolibarr releases will translations be available? Are Transifex translations also synced to maintenance releases?

Sync is always done on develop and/or beta. So Transifex changes appear in all versions whose branch is created after the Transifex change (a sync is always done before creating a new branch). Once a branch is created, the new changes into Transifex will be available only for the next branch. The reason for this is that we do not manage branch/versions on Transifex (not yet).

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 the right side of the "=" as seen above, the code (the key portion) on the 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.


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 a 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 nonexisting 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.

Language.png Distribute or include your translation into core source

Once you start translating, it's a smart decision to share it, so it can be included in the official code of Dolibarr. If you keep it for you, others will not be able to improve it when new terms are added or previous terms are modified, and you will still have to manage the translation on your own.

If you translated through the Transifex system, there's nothing to be done. Your translation will be included in the next version of Dolibarr. No additional work! In technical terms, the translation will be exported from Transifex and imported into Dolibarr by our developers, at least once every month.

If, however, you translated directly in Dolibarr files, then you will first have to transfer those translations to Transifex before they can be included. So, really, you should start translating into Transifex. If you send us your translation through a Pull Request on Github, sadly, it will be overwritten by the next import from Transifex, so it would be very short-lived.

Note:

The reference language is en_US and is always complete. You can find it in the htdocs/langs/en_US/ folder. All other language files are likely to be slightly or highly incomplete, depending on the language.

If you are developing a new module, you are likely going to need the addition of new language variables. This is done exclusively through the update of the en_US language (htdocs/langs/en_US/ folder). Just modify these files to add the variable you need and send the resulting folder as part of your Pull Request. Refer to the developer documentation to learn how to contribute code (you will need an account on https://github.com/Dolibarr/dolibarr.

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.


How to translate an existing page ?

Create a new page for the translated version.

Start by creating a new page for the translated version. To do this, you can access an non existant URL : for example https://wiki.dolibarr.org/index.php/Ma_nouvelle_page_en_français

The chosen title for the translated version of the page should be the translation of the title of the original English page.