How to get list of translatable messages

2019-08-02 05:37发布

I know how to translate a natural language message into the user's language using gettext.

But now I am wondering how to obtain a list of all translatable messages in a given domain.

I have obtained a raw result with something like this:

strings /usr/share/locale/${LANG:0:2}/LC_MESSAGES/$DOMAIN.mo

but I am looking for a neater solution.

1条回答
来,给爷笑一个
2楼-- · 2019-08-02 06:39

The xgettext program extracts translatable strings from .po files, which are the source files for the .mo files found in /usr/share/locale. These .po files should be included in the source distribution of the package for which you want to translate messages.

If you need to work with .mo files, you can translate them back to .po with msgunfmt.

查看更多
登录 后发表回答