如何使用POEdit从特定的域获取(可翻译)字符串 [英] How to get (translatable) strings from specific domain with POEdit
问题描述
我一直在努力寻找一种方法来设置 POEdit ,以便它可以从特定的文本中获取文本仅限域
I have been trying for hours finding a way to setup POEdit so that it can grab the text from specific domain only
我的gettext函数如下所示:
My gettext function looks like this:
function ri($id, $parameters = array(), $domain = 'default', $locale = null)
一个示例调用:
echo ri('Text %xyz%', array('%xyz%'=>100), 'myDomain');
我需要仅使用域myDomain来翻译文本才能翻译,或至少我想要POEdit将这些文本放入特定于域的文件。有没有办法?
I will need to grab only the text with the domain myDomain to translate, or at least I want POEdit to put these texts into domain specific files. Is there a way to do it?
我发现了几个类似的问题,但答案并不真的告诉我该做什么(我想我是这样的noob它必须用简单的英文解释我才能理解):
I found several questions that are similar but the answers don't really tell me what to do (I think I'm such a noob it must be explained in plain English for me to understand):
推荐答案
所以我终于找到了几天的搜索结果,我终于找到了答案:
So I finally figured it out after days of searching, I finally found the answer here:
http://sourceforge.net/mailarchive/message.php?msg_id=27691818
-
xgettext识别字符串中的上下文,并在* .pot文件中给出一个msgctxt字段,这被识别为b y翻译软件作为
上下文,并显示为这样(检查Pootle的图像显示上下文
以下)
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:
- 代码中的字符串应为格式_t('context','string' );和xgettext的调用应该是--keyword = _t:1c,2
(这基本上解释为xgettext在
中有两个参数是关键字函数,第一个是上下文,第二个是字符串) - 格式为_t('string','context')的代码中的字符串;并且xgettext的调用应该是--keyword = _t:1,2c
- 代码中的字符串应该是_t('context | string'),而xgettext的调用应该在表单--keyword = _t:1g
所以要回答我自己的问题,我把它添加到Poedit的sources keywords标签中:
So to answer my own question, I added this to the "sources keywords" tab of Poedit:
ri:1,3c
ri是函数名,1是stringid的位置,3是上下文/域的位置
ri is the function name, 1 is the location of the stringid, 3 is the location of the context/domain
希望这有助于别人,我讨厌所有这些隐秘文件
Hope this helps someone else, I hate all these cryptic documents
这篇关于如何使用POEdit从特定的域获取(可翻译)字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!