情况:使用gettext支持应用程序本地化时,有时希望使用dgettext('domain','some text string')指定一个域".但是,在运行 xgettext 时,所有用dgettext(...)包装的字符串都吐到一个文件中(默认值:messages.po). 给出以下示例: dgettext('menus', 'login link');dgettext('menus', 'account link');dgettext('footer', 'copyright notice');dgettext('footer', 'contact form');有什么方法可以结束 menus.pofooter.po使用诸如xgettext之类的提取器? 需要PHP响应,尽管我认为这应该适用于所有语言 解决方案我发现做到这一点的唯一方法是重新定义gettext函数...示例:function _menus ($str) { return dgettext('menus', $str);}function _footer ($_str) { return dgettext('footer', $str);}_menus('login link');_menus('account link');_footer('copyright notice');_footer('contact form');否则,您只需要运行以下命令:xgettext [usual options] -k --keyword=_menus:1 -d menusxgettext [usual options] -k --keyword=_footer:1 -d footer再见!(Really surprised this isn't answered anywhere online; couple posts over the past few years with a similar question, but never answered. Let's hope the Stackoverflow crew can come to the rescue)Situation:When using gettext to support application localization, one sometimes wishes to specify a 'domain' with dgettext('domain', 'some text string'). However, when running xgettext, all strings wrapped with dgettext(...) are spit out into one file (default: messages.po).Given the following example:dgettext('menus', 'login link');dgettext('menus', 'account link');dgettext('footer', 'copyright notice');dgettext('footer', 'contact form');is there any way to end up withmenus.pofooter.pousing an extractor such as xgettext?PHP response desired, although I believe this should be applicable across all languages 解决方案 The only way I've found to do this is to redefine gettext functions...example:function _menus ($str) { return dgettext('menus', $str);}function _footer ($_str) { return dgettext('footer', $str);}_menus('login link');_menus('account link');_footer('copyright notice');_footer('contact form');else, you only have to run following commands:xgettext [usual options] -k --keyword=_menus:1 -d menusxgettext [usual options] -k --keyword=_footer:1 -d footerBye! 这篇关于xgettext只能用于提取特定的域字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-08 03:44