poedit无法识别_x [英] poedit doesn't recognize _x

查看:120
本文介绍了poedit无法识别_x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.po文件包含:

"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;"
"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n"

我的php/wordpress代码包含:

And my php/wordpress code contains:

_x( 'Add New', $this->post_type , $domain ),

我知道Poedit正在扫描该文件(所有其他可翻译字符串都在更新目录"中拾取,并共享相同的域).如果我将_x更改为__(并删除co​​ntext参数),它也会选择该参数.但是按照本文的说法,添加新"字符串不会在PoEdit中显示.

I know that Poedit is scanning that file (all the other translatable strings are picked up on "update catalog", and share the same domain). And if I change _x to __ (and remove the context parameter) it picks that one as well. But as it is written, the "Add New" string simply wont show in PoEdit.

即使我手动将字符串添加到po文件中,在尝试从源代码更新为.po文件之后,它也会将其放入过时的字符串"中.

Even if I add manually the string to the po file, it will put it in the "obsolete strings" after trying to update to .po file from sources...

会以为"_x:1,2c;"一点就足以拿起字符串,但永远不会.

Would have thought that the "_x:1,2c;" bit would be enough to pick up the string, but it never does.

我在做错什么吗,还是遇到了实际的错误?

Is there something I'm doing wrong, or have I encountered an actual bug?

推荐答案

有关_x()的文档,请参见 http://codex.wordpress.org/Function_Reference/_x -第二个参数是context,它是PO中包含的字符串以及源文本,用于消除其他含义相同的相同字符串的歧义.上面的Codex页面有一个示例.另一个是可以在不同上下文中使用的开放",因此程序员可以使用例如以文件菜单"为上下文.

See the documentation for _x() at http://codex.wordpress.org/Function_Reference/_x — the second argument is context, which is a string included in the PO together with the source text to disambiguate otherwise identical strings with different meaning. The codex page above has an example; another one is e.g. "Open" that could be used in different context, so the programmer would use e.g. "File menu" as the context.

重要的部分是它的处理方式与要翻译的文本相同.文本必须是字符串文字,以便xgettext提取它,上下文也是如此(它必须是:它已放入PO文件中!).

The important part is that it is handled the same way as the text to be translated. The text has to be a string literal for xgettext to extract it and so does the context (it has to be: it's something that goes into the PO file!).

$this->post_type不是文字,这就是为什么xgettext无法识别它的原因.它不可能知道运行时的post_type值是什么,因此它不可能知道要写入已创建的PO文件中的内容.

$this->post_type is not a literal, which is why xgettext doesn't recognize it. There's no way it could know what the post_type value could be at runtime and so it couldn't possibly know what to write into the created PO file.

要解决此问题,您需要至少在前两个参数字符串文字中使用_x().

To fix this, you need to use _x() with at least the first two arguments string literals.

这篇关于poedit无法识别_x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆