WordPress l18n _x() 函数
我正在尝试理解 WordPress 函数 _x()。根据 WordPress 网站的解释,在通过上下文消歧时使用 _x() 。例子如下:
if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
...
// some other place in the code
echo _x('Comment', 'column name');
根据我的理解:对于“Comment”,有两种翻译。一个用于“名词”,另一个用于“列名称”。如果我是对的,那么:
1)PO文件的格式是什么?
2)如何使用第二个参数“名词”或“列名称”检索翻译?
I'm trying to understand WordPress function _x(). According to WordPress website explanation that uses _x() when disambiguation by context. The example is as follows:
if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
...
// some other place in the code
echo _x('Comment', 'column name');
From my understanding: for "Comment", there are two translations. One is for "noun", another is for "column name". If i am right, then:
1) what is the format of PO file?
2) how to retrieve the translation by using second parameter: "noun" or "column name"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是函数
_x()
的样子WordPress 中的用法是 $context 是使用该字符串的“区域”。我在文件 /wp-admin/network/users.php 中找到了
_x()
,它的使用方式如下:我认为您的情况没有任何理由使用
_x ()
而不是__()
和多个字符串。要编辑 PO 文件,您可以使用 Poedit 之类的工具: http://www.poedit.net/download.php< /a>
This is what the function
_x()
looks likeThe usage in WordPress is that $context is the "area" of which the string is used. I found
_x()
in the file /wp-admin/network/users.php where it was used like this:I don't think that there's any reason in your case to use
_x()
instead of__()
and multiple strings.For editing PO files you could use something like Poedit: http://www.poedit.net/download.php