我已经尝试了几个小时寻找设置方法 POEdit这样它就可以仅从特定域获取文本
我的 gettext 函数如下所示:
function ri($id, $parameters = array(), $domain = 'default', $locale = null)
示例调用:
echo ri('Text %xyz%', array('%xyz%'=>100), 'myDomain');
我只需要获取域 myDomain 的文本进行翻译,或者至少我希望 POEdit 将这些文本放入特定于域的文件中。有办法做到吗?
我发现了几个类似的问题,但答案并没有真正告诉我该怎么做(我认为我是个菜鸟,必须用简单的英语解释才能让我理解):
最佳答案
经过几天的搜索,我终于弄清楚了,我终于在这里找到了答案:
http://sourceforge.net/mailarchive/message.php?msg_id=27691818
xgettext recognizes context in strings, and gives a msgctxt field in the *.pot file, which is recognized by translation software as a context and is shown as such (check image of Pootle showing context below)
This can be done in 3 ways:
- String in code should be in the format _t('context','string'); and xgettext invocation should be in the form --keyword=_t:1c,2 (this basically explains to xgettext that there are 2 arguments in the keyword function, 1st one is context, 2nd one is string)
- String in code in the format _t('string','context'); and xgettext invocation should be in the form --keyword=_t:1,2c
- String in the code should be as _t('context|string') and xgettext invocation should be in the form --keyword=_t:1g
为了回答我自己的问题,我将其添加到 Poedit 的“来源关键字”选项卡中:
ri:1,3c
ri 是函数名,1 是 stringid 的位置,3 是上下文/域的位置
希望这对其他人有帮助,我讨厌所有这些神秘的文档
关于dns - 如何使用 POEdit 从特定域获取(可翻译)字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12743214/