WordPress l18n _x() 函数 [英] WordPress l18n _x() function
问题描述
我正在尝试理解 WordPress 函数 _x().根据 WordPress 网站解释,在按上下文消歧时使用 _x().例子如下:
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');
根据我的理解:对于Comment",有两种翻译.一个是名词",另一个是列名".如果我是对的,那么:
From my understanding: for "Comment", there are two translations. One is for "noun", another is for "column name". If i am right, then:
1) PO 文件的格式是什么?
1) what is the format of PO file?
2) 如何通过使用第二个参数:名词"或列名"来检索翻译?
2) how to retrieve the translation by using second parameter: "noun" or "column name"?
推荐答案
这是_x()
函数的样子
_x($single, string $context, [string $domain = 'default'], string $text)
WordPress 中的用法是 $context 是使用字符串的区域".我在文件/wp-admin/network/users.php 中找到了 _x()
,它是这样使用的:
The 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:
_x( 'Users', 'users per page (screen options)' )
我认为在您的情况下没有任何理由使用 _x()
而不是 __()
和多个字符串.
I don't think that there's any reason in your case to use _x()
instead of __()
and multiple strings.
要编辑 PO 文件,您可以使用类似 Poedit:http://www.poedit.net/download.php
For editing PO files you could use something like Poedit: http://www.poedit.net/download.php
这篇关于WordPress l18n _x() 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!