前言
現在一直在使用CloudStack,期間坑無數。當然了,官方文檔也有坑。很多處錯誤。
另外,發現越來越多的人在使用CloudStack時,太急躁了,往往一上來就想一下子把所有東西搞透,那怎麼可能呢。
官方文檔寫的再爛,也有它存在的道理,恰恰好多人都不注重看文檔。出錯了都不知道從哪裏查起。。。
當然了,在我看來,吹的再好的產品,文檔寫得不好,那也白瞎。
CS一直都存在的問題就是文檔國際化跟不上,中文翻譯也不全,這也許也是很多人不喜歡看文檔的原因吧。
最近一直琢磨着翻一下官方文檔,今天上www.transifex.com瞅了瞅cloudstack項目下的語言翻譯進度。。。
媽呀,連中文庫都沒。。。只有英語和日語。
實在是忍無可忍了,遂申請創建了中文庫,晚上得到回覆。可以開工了。
一個人翻譯能力畢竟有限,進度緩慢,遂寫這篇文章,指導大家建立CS文檔翻譯環境。造福大家。
個人純粹出於造福大家的目的
備註:
由於我也不懂sphinx,所以耽誤了很多時間在摸索上面。
相關鏈接
要翻譯的鏈接:
Installation 4.3:https://github.com/apache/cloudstack-docs-install
Administrators 4.3:https://github.com/apache/cloudstack-docs-admin
Release notes 4.3:https://github.com/apache/cloudstack-docs-rn
對應的本地化網站鏈接爲:
準備
一、本地環境準備
RHEL/CentOS/Ubuntu/Debian:
#python要求2.6以上
#安裝Sphinx及transifex-client
#安裝Shpinx主題
pip install sphinx_rtd_theme
二、獲取Docs源碼
#創建文檔存放路徑
mkdir /opt/CloudStack-docs/ cd /opt/CloudStack-docs/
1.github上面獲得源碼:
git clonehttps://github.com/apache/cloudstack-docs-install.git git clonehttps://github.com/apache/cloudstack-docs-admin.git git clonehttps://github.com/apache/cloudstack-docs-rn.git
配置
1.修改source/conf.py文件
添加和修改如下信息:
import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
2.清空build目錄
make clean
3.生成.pot文件
make gettext
4.生成.tx/config文件(用於transifex網站更新及推送)
#首先需要進行transifex客戶端設置,需要有帳號,沒有的可以去該網站註冊
#tx init --user=<transifex-username> --pass=<transifex-password> Creating .tx folder... Transifex instance [https://www.transifex.com]: ... #sphinx-intl update-txconfig-resources --pot-dir source/locale/pot --transifex-project-name apache-cloudstack-installation-rtd --locale-dir source/locale
5.創建zh_CN中文目錄
mkdir –p source/locale/ja/LC_MESSAGES
6.下載最新的zh_CN po文件(方法一)
tx pull -l zh_CN
同步完成後,驗證:
ls source/locale/zh_CN/LC_MESSAGES/
可以看到很多po文件,該文件可以直接進行翻譯編輯。
7.自行建立zh_CN的po文件(方法二):
msginit --locale=zh_CN --input=source/locale/pot/index.pot --output=source/locale/zh_CN/LC_MESSAGES/index.po
使用如上命令,依次將source/locale/pot/目錄下的所有pot文件,轉換成po文件。
轉換後即可直接進行po文件的翻譯編寫。
8.構建翻譯後的文檔
#將翻譯好的po文件轉換爲mo文件
sphinx-intl --locale-dir=source/locale/ --language=zh_CN build
#創建單一的html文檔(zh_CN)
make singlehtml SPHINXLANG=zh_CN
#創建html文檔(zh_CN)
make html SPHINXLANG=zh_CN
驗證
進入html文檔目錄
cd build/singlehtml
可將此目錄拷貝至apache或nginx根目錄,或者本地瀏覽查看。
如果沒有安裝apache或nginx,可臨時使用“
python -m SimpleHTTPServer 80”打開一個web服務器。
或者將翻譯好的po文件上傳至對應的如上鍊接中:
另,附上Sphinx項目流程圖: