gpt4 book ai didi

localization - xgettext 能否仅用于提取特定域字符串?

转载 作者:行者123 更新时间:2023-12-04 04:11:11 26 4
gpt4 key购买 nike

(真的很惊讶这个问题在任何地方都没有在线回答;过去几年有几个帖子提出了类似的问题,但从未回答过。希望 Stackoverflow 的工作人员能来拯救)

情况:

当使用 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');

有什么办法可以结束

菜单.po
页脚.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 menus
xgettext [usual options] -k --keyword=_footer:1 -d footer

再见!

关于localization - xgettext 能否仅用于提取特定域字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3341829/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com