Can I automatically update msgids in gettext's .po files for trivial text changes?

一世执手 提交于 2019-12-03 14:42:33

One way to avoid the problem is to leave the msgids alone, have a .po file for the original language and make the fix inside that.

It always strikes me as being more of a work around than a proper fix though. For the next iteration (where there will definitely be more msgid changes) the msgid is changed and either the translators translate it in their usual update or each language is updated by hand when the msgid is changed.

I've had exactly this issue when doing minor changes to a django project. What I do is the following:

  1. Change message in code.
  2. Run find and replace on all translation files ("django.po"), replacing the old message (msgid) with the new one.
  3. Run django-admin makemessages.

If I have done things right, the last step is superflous (i.e, you have done the change for gettext). django uses the gettext utilities, so it shouldn't matter how you make your message files.

I find and replace like so: find . -name "*.po" -print | xargs sed -i 's/oldmessageid/newmessageid/g' Courtesy of http://rushi.vishavadia.com/blog/find-replace-across-multiple-files-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!