zabbix是一個多語言監控系統,界面顯示由對應的語言下的frontend.mo控制。當前對中文的翻譯不完全,如下圖
如果我們需要自己優化,將此翻譯成中文,那么你需要修改zh_CN下的frontend.po,然后make_mo.sh創建frontend.mo。下面以
為例,介紹zabbix界面的漢化過程。
漢化例子
1、確認要修改的po文件的位置
[root@zabbix ~]# find / -name frontend.po /root/cn_LC_MESSAGES/frontend.po /usr/share/zabbix/locale/bg/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/cs/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/de/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/el/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/en_US/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/es/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/fa/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/fi/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/fr/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/hu/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/id/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/it/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/ja/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/ko/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/lt/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/lv/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/nl/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/pl/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/pt_BR/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/pt_PT/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/ro/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/ru/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/sk/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/sv/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/tr/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/uk/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/vi/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/zh_CN/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/zh_TW/LC_MESSAGES/frontend.po /usr/share/zabbix/locale/ka/LC_MESSAGES/frontend.po
2、添加中文內容到frontend.po
[root@zabbix LC_MESSAGES]# vim frontend.po
將
#: include/blocks.inc.php:486 msgid "Number of items (enabled/disabled/not supported)" msgstr ""
修改為
#: include/blocks.inc.php:486 msgid "Number of items (enabled/disabled/not supported)" msgstr "監控項(啟用/禁用/不支持)"
3、創建.mo文件
/usr/share/zabbix/locale/make_mo.sh
4、刷新界面,發現已經變成了中文
po文件編輯工具推薦---Poedit
使用vim編輯frontend.po是一種辦法,也可以使用專門的圖形化工具Poedit對po文件進行編輯、編譯。該工具具有翻譯建議
2、
將生成的frontend.mo替換掉/usr/share/zabbix/locale/zh_CN/LC_MESSAGES下的frontend.po 即可。
gettext工具簡介
zabbix提供的腳本 /usr/share/zabbix/locale/make_mo.sh 實現語言文件po到mo的轉換,其實/usr/share/zabbix/locale/make_mo.sh調用的就是gettext中的gettext。
[root@zabbix locale]# cat /usr/share/zabbix/locale/make_mo.sh #!/bin/bash while read pofile; do msgfmt --use-fuzzy -c -o ${pofile%po}mo $pofile done < <(find $(dirname $0) -type f ! -wholename '*/.svn*' -name '*.po')
gettext工具下載地址:http://gnuwin32.sourceforge.net/packages/gettext.htm
gettext包中包含了msgunfmt.exe、msgfmt.exe 等文件,可以實現語言文件po和mo的互相轉換
根據po生成mo
重新生成mo文件
cd C:\Software\GetText\bin
msgfmt.exe C:\Users\xqzt\Desktop\當前\frontend.po -o C:\Users\xqzt\Desktop\當前\frontend.mo
根據mo生成po
cd C:\Software\GetText\bin
msgunfmt.exe C:\Users\xqzt\Desktop\frontend.mo -o C:\Users\xqzt\Desktop\frontend.po