开发者

Gettext: Different path for message catalogs

In a Python application that uses gettext to provide support for internationalization, I would like to change the path of the *.mo message catalogs to po/language.mo instead of the default localedir/language/LC_MESSAGES/domain.mo, as I would like to use Launchpad's translation interface, which requires this naming scheme (at least as far as I understood [1]).

However, after reading the module documentation, I can't seem to find a way to do this without monkey-patching the gettext module. Is there an 'official' way to do it?

[1] https://help.launchpad.net/Translations/YourProject/Exports


开发者_如何学编程

edit: Thinking about it for a while, changing the path is not actually necessary for Launchpad-integration, as it only cares about the *.po files, not the compiled *.mo files. My question still remains, though, as it would be nice if the application messed around with system directories as little as possible (especially considering that it's a multi-platform app that runs on *nix, Windows and OS X).


I asked the same question for PHP, but the answer lies in the underlying gettext api. It's not possible to change the path for catalogs.

The directory structure is fixed by gettext.

Because many different languages for many different packages have to be stored we need some way to add these information to file message catalog files. The way usually used in Unix environments is have this encoding in the file name. This is also done here. The directory name given in bindtextdomains second argument (or the default directory), followed by the name of the locale, the locale category, and the domain name are concatenated:

dir_name/locale/LC_category/domain_name.mo

See: PHP Gettext: how to change the default MO path after setting the path of the domain?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜