31,003
edits
mNo edit summary Tag: 2017 source edit |
|||
| Line 49: | Line 49: | ||
First install TX Client. | First install TX Client. | ||
With Debian/Ubuntu/Mint: | With Debian/Ubuntu/Mint: | ||
< | <syntaxhighlight lang="bash"> | ||
apt-get install python-pip | apt-get install python-pip | ||
pip install transifex-client | pip install transifex-client | ||
</ | </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. | ||
< | <syntaxhighlight lang="bash"> | ||
cd git/dolibarr | cd git/dolibarr | ||
tx init | tx init | ||
</ | </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 91: | Line 91: | ||
That is a sample of what the config file contains: | That is a sample of what the config file contains: | ||
< | <syntaxhighlight lang="ini"> | ||
[main] | [main] | ||
host = https://www.transifex.com | host = https://www.transifex.com | ||
| Line 101: | Line 101: | ||
source_lang = en_US | source_lang = en_US | ||
type = MOZILLAPROPERTIES | type = MOZILLAPROPERTIES | ||
</ | </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 157: | ||
To pull translation files, you can use: | To pull translation files, you can use: | ||
< | <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 | ||
</ | </syntaxhighlight> | ||
To push source files, just type: | To push source files, just type: | ||
< | <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 | ||
</ | </syntaxhighlight> | ||
===Other questions on transifex process=== | ===Other questions on transifex process=== | ||
| Line 192: | Line 192: | ||
These files have the format of key/value pairs in each line like the followings: | These files have the format of key/value pairs in each line like the followings: | ||
< | <syntaxhighlight lang="ini"> | ||
Code1 = translate phrase 1 | Code1 = translate phrase 1 | ||
Code2 = translate phrase 2 | Code2 = translate phrase 2 | ||
... | ... | ||
Coden = translate phrase n | Coden = translate phrase n | ||
</ | </syntaxhighlight> | ||
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. | 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. | ||
| Line 203: | Line 203: | ||
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: | 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: | ||
< | <syntaxhighlight lang="PHP"> | ||
$langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX | $langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX | ||
print $langs->trans("CodeX") | print $langs->trans("CodeX") | ||
</ | </syntaxhighlight> | ||
An entry type; | An entry type; | ||
< | <syntaxhighlight lang="ini"> | ||
CodeX = phrase X | CodeX = phrase X | ||
</ | </syntaxhighlight> | ||
must be present or added to the myfile.lang file. | must be present or added to the myfile.lang file. | ||
| Line 226: | Line 226: | ||
To make or update all files of a language code, just run the script: | To make or update all files of a language code, just run the script: | ||
< | <syntaxhighlight lang="bash"> | ||
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY | php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY | ||
</ | </syntaxhighlight> | ||
For example : | For example : | ||
< | <syntaxhighlight lang="bash"> | ||
php autotranslator.php en_US pt_PT GOOGLEAPIKEY | php autotranslator.php en_US pt_PT GOOGLEAPIKEY | ||
</ | </syntaxhighlight> | ||
to translate into Portuguese (pt_PT) using English (en_US) files. | to translate into Portuguese (pt_PT) using English (en_US) files. | ||