中文翻譯文檔

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

Language.png Dolibarr簡體中文漢化教程

參考:duuge。com/archives/Dolibarr.html DolibarrQQ群原創:206239089 (簡體中文翻譯交流)
Dolibarr 語言文件已經被翻譯成多國語言文件.

默認語言為 English 英語並且一直為完成狀態。其他語言尚有待您的大力貢獻。

本教程可以指引您完成一個語種的翻譯或者修正已翻譯的語言錯誤以及未審閱的翻譯。

Dolibarr 有以下三種不同的翻譯方式方法:

  1. 使用 Transifex 網站手工翻譯大法 (官方推薦此法).
  2. 手工編輯修改語言文件法
  3. 自動化翻譯: 自動翻譯法

通過Transifex專業翻譯網站在線翻譯 (推薦)

Transifex 是一個給翻譯項目提供在線翻譯平台的在線應用。該平台包括翻譯團隊和討論工具,翻譯記憶,術語表,校對等N多功能。 此平台相當容用並且全部翻譯人員能夠從WEB網頁或使用該平台專用的TX命令行客戶端上傳及下載翻譯成果 Transifex 是一個開源項目並且其社區版本允許免費下載並安裝使用,但我們Dolibarr官方使用的是transifex網站的在線服務。

通過網頁在線漢化 (翻譯人員)

如果您想幫助Dolibarr翻譯完善您的語言,請點擊 https://www.transifex.com/dolibarr-association/dolibarr/

您事先需要註冊一個賬號並申請加入Dolibarr項目翻譯團隊中來。管理員會給你發封郵件告知你已經被管理團隊加入翻譯人員之中了。

一旦您認可,您即可開始翻譯啦。

更多信息, 請翻閱 Transifex 官方的"Getting Started" 翻譯嚮導介紹 http://docs.transifex.com/introduction/translators/ 以及編輯人員之旅 http://docs.transifex.com/tutorials/txeditor/

注意 en_US

web接口不可翻譯en_US源語言因為這是默認語言不允許動呀。 任何變更一定會體現在Dolibarr原始碼中的請放心我們會將您的提交pull到Dolibarr在github的源碼庫中的。

使用 TX 官方客戶端命令行工具 (這是給Dolibarr Category:Yoda 團隊看的你別看喲——其實我就看完了,嘿嘿嘿費玉清)

此處進行描述如何使用Transifex官方客戶端命令行工具。然而,這裏保留Dolibarr管理員們用於同步Dolibarr的Transifex主源碼。

Official documentation

TX 客戶端配置

首先當然是安裝 TX 客戶端程序軟件了. 基於 Debian/Ubuntu/Mint請使用以下安裝命令進行安裝: 當然首先要安裝python-pip

apt-get install python-pip

然後再安裝transifex-client

pip install transifex-client

byiz註:本人用上述方法安裝失敗,使用下面:

easy_install transifex-client

easy_install transifex-client.安裝成功, 然後對 TX 運行環境初始化. 即切換到dolibarr根目錄下之後運行 tx init 命令. 必須要先tx init初始化才行哦,見duuge筆記記錄全文這裏不再累述。

cd git/dolibarr
tx init

同意蓋掉config配置文件。全部保持默認值即可。因為咱也不懂想改也不知道改哪裏就保持默認了一路按回車吧。最後回車不下去了原來是需要輸入transifex的賬號和密碼呢。

做完上邊動作,會在當前用戶的HOME目錄下生成隱藏文件 .transifexrc ,這是這條命令用root權限 .tx/config 生成的. 目錄類似如下這樣子吧(我本人的不是,我是直接mkdir一個新目錄dolibarr-tx目錄用來專門放翻譯語言避免搞混了源文呀):

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

當然這個 config 配置文件可從 https://github.com/Dolibarr/dolibarr/tree/develop/.tx 下載得到的啦別擔心, 下載回來並放到 .tx 目錄中去, 蓋掉因為使用命令 tx init 而生成的那個配置文件哦。

此項目配置文件用於說明項目的詳情和文件與源碼的映射對應。

下邊有一個簡潔的 config 配置文件所包含有哪些元素不包生仔哦:

[main]
host = https://www.transifex.com
lang_map = uz: uz_UZ, sw: sw_SW, sr@latin: sr_RS

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[dolibarr.languages-not-res]
file_filter = htdocs/langs/<lang>/languages.lang
source_file = htdocs/langs/en_US/languages.lang
source_lang = en_US
type = MOZILLAPROPERTIES

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

這裏有專門解釋config配置文件的章節哦:

[main] section

本章節中我們有項目範圍的選項,默認transifex為全部的項目的伺服器。你也可以自建伺服器然後需要修改這裏相對應的選項。、

[dolibarr.resource]

source_lang: 這是資源的源語言.
source_file: 這直接指向源文件.
file_filter: 在這裏,我們保持用於識別特定項目下的翻譯文件的表達式。 not mandatory
trans.<lang>: 這是用於翻譯的文件,不遵循一個共同的命名模式和文件的表達不能被用來跟蹤他們。 not mandatory
host: 萬一項目不使用默認的Transifex伺服器那麼就在 [main] 這裏標記設定, it can override it using this option. not mandatory

TX 使用方法簡要說明

一些有用的TX命令的 tx 幫助信息.

tx status

顯示翻譯狀態

tx push

使用push命令將你本地計算機中的翻譯文件push上傳到Transifex伺服器
更多的tx push命令的幫助信息如下:

-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

使用pull命令將Transifex伺服器的翻譯文件pull下載到你本地計算機中
更多的tx pull命令的幫助信息如下:

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

示例

從transefix拉取翻譯文件回來, 可用如下命令:

tx -d pull -l zh_CN  # 仅拉取简体中文语言
tx -d pull -a   # 拉取全部语言

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

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

有關 transifex 的其他問題

下面是三個 transifex 翻譯相關的疑問及官方解答:

1) 這是定期同步到Dolibarr中去的嗎?定期多久呢 ?

不。這不是定期的。因此也不存在定期多久的問題。 當翻譯的提交足夠多的時候。 這些翻譯結果也作為 beta branch 分支或者最終穩定版本中使用。

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 review before sync is done. Making review is above all to know which lines were manually reviewed and which one were initially translated using a robot.

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 version whose branch is created after the transifex change (a sync is always done before creating a new branch). Once a branch is created, then new changes into transifex will be available only for next branch. Reason of this is that transifex is not able to manage branch/versions (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 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.


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.

Language.png Distribute or include your translation into core source

Including your translation in the official Dolibarr sources

Once you start translating, it's a smart decision to share it, so it can be included into 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.

Adding new variables

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.

As an extension

When you create a new language, if it is not already integrated into Dolibarr, it can still be broadcast to all other users. You can make a distribution package using the build/makepack-dolibarrlang.pl script or making a zip archive manually and posting it on dolistore.com or sending it to the developers' mailing list dolibarr-dev (https://savannah.nongnu.org/mail/?group=dolibarr).

New language files are immediately available in an installation as soon as the archive is unzipped in the correct directory.

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.