2011-09-21 177 views
12

我有一個帶有國際化字符串的python項目。 我修改了源代碼,並且字符串的行被改變了,即在pot和po文件中他的字符串沒有指向正確的行。Gettext:修改源文件後如何更新po和pot文件

那麼如何將po和pot文件更新爲文件中的新字符串位置。

回答

12

你可以看看this script用新代碼更新你的po文件。它使用xgettextmsgmerge

echo '' > messages.po # xgettext needs that file, and we need it empty 
find . -type f -iname "*.py" | xgettext -j -f - # this modifies messages.po 
msgmerge -N existing.po messages.po > new.po 
mv new.po existing.po 
rm messages.po 
+0

這是偉大的,你將二者結合起來的命令,我需要到一個。 +1 –

+0

在Windows上怎麼樣? – Manu

+0

@Manu:有一個[gettext for windows](http://gnuwin32.sourceforge.net/packages/gettext.htm) –

2

使用autoconfautomake,你可以簡單地改變成po子目錄,然後運行:

make update-po 

或:

make update-gmo