中文翻译文档: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
m (Replacing "<keywords content" tag by new "<seo metak" tag after migrating from MetaKeywordsTag extension to AddHTMLMetaAndTitle extension.)
mNo edit summary
Tag: 2017 source edit
 
Line 44: Line 44:
基于 Debian/Ubuntu/Mint请使用以下安装命令进行安装:
基于 Debian/Ubuntu/Mint请使用以下安装命令进行安装:
当然首先要安装python-pip
当然首先要安装python-pip
<source lang="bash">
<syntaxHighlight lang="bash">
apt-get install python-pip
apt-get install python-pip
</source>
</syntaxHighlight>
然后再安装transifex-client
然后再安装transifex-client
<source lang="bash">
<syntaxHighlight lang="bash">
pip install transifex-client
pip install transifex-client
</source>
</syntaxHighlight>
byiz注:本人用上述方法安装失败,使用下面:
byiz注:本人用上述方法安装失败,使用下面:
<source lang="bash">
<syntaxHighlight lang="bash">
easy_install transifex-client
easy_install transifex-client
</source>
</syntaxHighlight>
easy_install transifex-client.安装成功,
easy_install transifex-client.安装成功,
然后对 TX 运行环境初始化. 即切换到dolibarr根目录下之后运行 '''tx init''' 命令.
然后对 TX 运行环境初始化. 即切换到dolibarr根目录下之后运行 '''tx init''' 命令.
必须要先tx init初始化才行哦,见duuge笔记记录全文这里不再累述。
必须要先tx init初始化才行哦,见duuge笔记记录全文这里不再累述。
<source lang="bash">
<syntaxHighlight lang="bash">
cd git/dolibarr
cd git/dolibarr
tx init
tx init
</source>
</syntaxHighlight>
同意盖掉config配置文件。全部保持默认值即可。因为咱也不懂想改也不知道改哪里就保持默认了一路按回车吧。最后回车不下去了原来是需要输入transifex的账号和密码呢。
同意盖掉config配置文件。全部保持默认值即可。因为咱也不懂想改也不知道改哪里就保持默认了一路按回车吧。最后回车不下去了原来是需要输入transifex的账号和密码呢。


Line 95: Line 95:
下边有一个简洁的 config 配置文件所包含有哪些元素不包生仔哦:
下边有一个简洁的 config 配置文件所包含有哪些元素不包生仔哦:


<source lang="ini">
<syntaxHighlight lang="ini">
[main]
[main]
host = https://www.transifex.com
host = https://www.transifex.com
Line 465: Line 465:
source_lang = en_US
source_lang = en_US
type = MOZILLAPROPERTIES
type = MOZILLAPROPERTIES
</source>
</syntaxHighlight>


这里有专门解释config配置文件的章节哦:
这里有专门解释config配置文件的章节哦:
Line 521: Line 521:
从transefix拉取翻译文件回来, 可用如下命令:
从transefix拉取翻译文件回来, 可用如下命令:


<source lang="bash">
<syntaxHighlight lang="bash">
tx -d pull -l zh_CN  # 仅拉取简体中文语言
tx -d pull -l zh_CN  # 仅拉取简体中文语言
tx -d pull -a  # 拉取全部语言
tx -d pull -a  # 拉取全部语言
</source>
</syntaxHighlight>


推送本地翻译源文件到transefix去, 输入以下命令即可:
推送本地翻译源文件到transefix去, 输入以下命令即可:


<source lang="bash">
<syntaxHighlight lang="bash">
tx -d push -t -l zh_CN [-r dolibarr.file]  # 仅推送指定的zh_CN简体中文语言的翻译源文件到trasefix去
tx -d push -t -l zh_CN [-r dolibarr.file]  # 仅推送指定的zh_CN简体中文语言的翻译源文件到trasefix去
tx -d push -s  # To push source file
tx -d push -s  # To push source file
</source>
</syntaxHighlight>


=== 有关 transifex 的其他问题 ===
=== 有关 transifex 的其他问题 ===
Line 556: Line 556:
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:


<source lang="ini">
<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
</source>
</syntaxHighlight>


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.
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.
Line 567: Line 567:
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:


<source lang="php">
<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")
</source>
</syntaxHighlight>


An entry type;
An entry type;


<source lang="ini">
<syntaxHighlight lang="ini">
CodeX = phrase X
CodeX = phrase X
</source>
</syntaxHighlight>


must be present or added to the myfile.lang file.
must be present or added to the myfile.lang file.
Line 589: Line 589:


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:
<source lang="bash">
<syntaxHighlight lang="bash">
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY
</source>
</syntaxHighlight>
For example :
For example :
<source lang="bash">
<syntaxHighlight lang="bash">
php autotranslator.php en_US pt_PT GOOGLEAPIKEY
php autotranslator.php en_US pt_PT GOOGLEAPIKEY
</source>
</syntaxHighlight>
to translate into Portuguese (pt_PT) using English (en_US) files.
to translate into Portuguese (pt_PT) using English (en_US) files.


Navigation menu