dns - 如何使用 POEdit 从特定域获取(可翻译)字符串

标签 dns gettext poedit

我已经尝试了几个小时寻找设置方法 POEdit这样它就可以仅从特定域获取文本

我的 gettext 函数如下所示:

function ri($id, $parameters = array(), $domain = 'default', $locale = null)

示例调用:

echo ri('Text %xyz%', array('%xyz%'=>100), 'myDomain');

我只需要获取域 myDomain 的文本进行翻译,或者至少我希望 POEdit 将这些文本放入特定于域的文件中。有办法做到吗?

我发现了几个类似的问题,但答案并没有真正告诉我该怎么做(我认为我是个菜鸟,必须用简单的英语解释才能让我理解):

How to set gettext text domain in Poedit?

How to get list of translatable messages

最佳答案

经过几天的搜索,我终于弄清楚了,我终于在这里找到了答案:

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:

      1. 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)
      2. String in code in the format _t('string','context'); and xgettext invocation should be in the form --keyword=_t:1,2c
      3. 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/

相关文章:

sockets - UDP 套接字未从 Go 中的服务器读取

ssl - Jenkins 插件管理器 : Updating plugin data fails

facebook - 在本地测试 "Facebook Login"

python - Django makemessages "struct.error: unpack requires a buffer of 4 bytes"

java - Java 中是否有替代 gettext _() 方法的好方法?

php - 是否可以将 gettext 与来自 mysqli_query 的数据一起使用?

localization - 使用 PoEditor 添加翻译

go - 如何为网络包设置 DNS 缓存?

使用 xgettext 的 Python 行号

poedit - 如何找到 POEdit 错误