多國語言i18n -- i18ndude

i18ndude 是plone上建立多語系網站最強大且重要的工具,利用i18ndude,可以輕鬆建立多語系網站,筆者過去曾接觸過wordpress / joomla / xoops等多套CMS,從沒看過如此強大的多語系工具,也因為多語系這項特色,plone在歐洲廣受歐盟各官方及NGO網站所採用

實際作法如下

1.確認模組內設定檔configure.zcml存在 多國語言i18n 設定,沒有的話,自行加上

<configure xmlns:i18n="http://namespaces.zope.org/i18n">
  <i18n:registerTranslations directory="locales" />
</configure>

2.在模組目錄下,必需有以下檔案及目錄,沒有的話,先以mkdir, touch建好

locales/foo.bar.pot
locales/zh_TW/LC_MESSAGES/
locales/zh_TW/LC_MESSAGES/foo.bar.po

3.在模組目錄下,執行以下指令

../../../../bin/i18ndude rebuild-pot --pot locales/foo.bar.pot --create foo.bar .

如此,i18ndude會自動掃描foo.bar內,所有py, pt檔內,可以使用i18n的文字片段,並寫入foo.bar.pot

4.接著,執行

../../../../bin/i18ndude sync --pot locales/foo.bar.pot locales/*/LC_MESSAGES/foo.bar.po

會自動產生.po檔,

5.最後,就是手動編輯.po檔的內容,將文字都翻成中文吧

<div6.重複以上1-5步驟,即可為你自行開發的模組,建立起各種語言的語言套件