翻譯 Dolibarr
Dolibarr語言文件已經用幾種語言翻譯了。 英語是默認的語言會首先完成翻譯。其他語言依賴於自願者的貢獻。 本教程幫助您完成一個未譯的或錯譯的語言。 Dolibarr可以用三種不同的方式翻譯:
- 手動使用Transifex (官方和推薦的方法)
- 手動編輯語言文件
- 全自動:自動翻譯機
使用Transifex在線服務進行手動翻譯(推薦)
Transifex 是一個為翻譯項目提供在線平台的Web應用程式。它包括團隊和討論工具、翻譯記憶、詞彙表、校對和許多其他特徵。 它非常容易使用,所有翻譯都可以通過Web界面上傳或下載,或者使用來自終端的TX客戶端。 Transifex 是一個開源項目,「社區版」可以免費下載和安裝,但我們將使用在線託管服務。
使用Web界面(譯者)
如果你想用自己的語言幫助翻譯Dolibarr,請檢查項目的頁面。 https://www.transifex.com/dolibarr-association/dolibarr/
然後,您可以註冊一個帳戶,並請求加入項目團隊,以您的語言為目標。管理員會接受你的要求,所以請耐心等待。
一旦被接受,你就可以馬上開始翻譯了。
欲了解更多信息,請檢查Transifex「入門」介紹規範 http://docs.transifex.com/introduction/translators/ 和網絡編輯器嚮導於 http://docs.transifex.com/tutorials/txeditor/
備註關於 en_US
Web界面不能用來翻譯原始碼的en_US語言。
任何更改都必須在Dolibarr原始碼中完成,並在GitHub存儲庫上使用Pull請求提交。
使用TX 命令行客戶端 (for Dolibarr Category:Yoda team)
這描述了如何從命令行中使用Transifex。然而,這是保留給Dolibarr管理員用戶,以同步Transifex與Dolibarr主源碼。
TX 客戶端設置
安裝 TX 客戶端 使用 Debian/Ubuntu/Mint:
apt-get install python-pip
pip install transifex-client
然後你必須初始化你的TX環境。這是通過進入Dolibarr項目根目錄運行'tx init 來完成的。
cd git/dolibarr
tx init
接受改寫配置文件。保持Transifex實例的默認值,然後輸入您的Transifex登錄和密碼。
在此之後,一個.transifexrc已經創建到您的主頁目錄,並且一個通用配置文件被創建於項目根目錄中的.tx/config。 所以目錄的內容會是這樣的: 所以目錄的內容會是這樣的:
.
|-- 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
當前配置文件可以從 https://github.com/Dolibarr/dolibarr/tree/develop/.tx 下載,放入.tx目錄,重寫由'tx init 創建的目錄。
此項目配置文件用於將項目的詳細信息和文件存儲到資源映射。
這是配置文件包含內容的示例:
[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
下面是配置文件中使用的部件和選項的說明:
[main] section
在本節中,我們有項目範圍的選項,例如:所有項目的默認transifex主機。如果需要的話,這些資源可以被每個資源重寫。
[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 客戶端使用
tx 命令有用的信息。
tx status
顯示翻譯狀態
tx push
用於推送更改,從你的計算機到Transifex伺服器
TX推送命令的其他選項是:
-h - 显示命令行帮助
-l <lang> - 指定要推送哪些翻译(默认为所有)
-r <resource> - 指定要向其推送翻译的资源(默认为所有)
-f - 在不修改修改时间的情况下推送源文件
--skip - 错误时不要停止。当同时推多个文件时很有用。
-s - 将源文件推送到服务器
-t - 将翻译文件推送到服务器
--no-interactive - 强制推送时不需要用户输入。
tx pull
用於從Transifex伺服器將更改拉到您的計算機上
TX拉動命令的其他選項是:
-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.
例
要取得翻譯文檔,使用:
tx -d pull -l it_IT # Get italian language only
tx -d pull -a # Get all languages
要上傳源文件,鍵入:
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
transifex流程的其他問題
這是一個簡短的Q&A,你也可以問一下transifex翻譯過程:
1) 是在一個固定的時間間隔上的同步?
不,它是在有足夠的翻譯提交的地方完成的。在創建最終發佈包之前,它也在beta分支上完成。
2) 是否所有的翻譯同步到Git,或者僅僅是經過審查的翻譯。在同步完成之前我需要複習嗎? ?
當同步完成時,transifex文件將文件覆蓋到Git中,但前提是至少為文件修改了記錄。 在同步完成之前,您不必進行複查。最重要的是,要知道哪些線是手工評審的,哪些是最初用機械人翻譯的。
3) Dolibarr發佈的版本將有翻譯嗎?transifex 翻譯也與維護版本同步?
同步總是在開發和/或beta上完成。 因此,transifex更改出現在所有版本中,其分支是在transifex更改之後創建的(在創建新分支之前總是進行同步)。
一旦創建了一個分支,那麼新的過渡到transifex將只適用於下一個分支。這是因為transifex無法管理分支/版本(還沒有)。
手動翻譯(不推薦)
要將DoiBARR翻譯成另一種語言,請轉到Langs目錄,並創建一個用代碼語言命名的文件夾/目錄來翻譯(遵循現有格式,例如en_US, en_GB, es_ES, de_DE, 等)。然後將文件從現有的語言目錄(例如en_US/main.lang, en_GB/bills.lang)複製到剛剛創建的新語言目錄中。
這些文件在每行中具有鍵/值對的格式,如下所示:
Code1 = translate phrase 1
Code2 = translate phrase 2
...
Coden = translate phrase n
將短語(鍵值對的值部分)翻譯你的語言,「=」的左邊的代碼(鍵部分)應該保持不變。
可以逐個翻譯這些文件,而不必一次就把它們全部翻譯出來。
如果文件沒有被翻譯成新的語言,Dolibarr將使用英語。
要在PHP代碼中有一個本地化的(翻譯的)字符串,你所要做的就是加載語言文件並使用該方法得到翻譯值,如下所示:
$langs->load("myfile"); // or use $langs->load("myfile@mymodule") if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX
print $langs->trans("CodeX")
條目類型;
CodeX = phrase X
必須存在或添加到myfile.lang文件。
使用autotranslator.php工具自動翻譯
- 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.
將你的翻譯分發到核心資源中
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.
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.
翻譯Wiki文檔
維基是用3種語言寫成的:英語、法語和西班牙語。
如果你想增強這些語言中的一種語言,你所要做的就是在Wiki上創建一個帳戶。
然後,您可以編輯現有的頁面來糾正錯誤的翻譯或翻譯等待翻譯的頁面。 Category:Page_waiting_for_translation.