WordPress函数文档_x()
从获取的文本中返回翻译的字符串 描述 Retrieve translated string with gett…
从获取的文本中返回翻译的字符串
描述
Retrieve translated string with gettext context
Quite a few times, there will be collisions with similar translatable text found in more than two places but with different translated context.
By including the context in the pot file translators can translate the two strings differently.
用法
<?php $translated_text = _x( $text, $context, $domain ) ?>
参数
$text
(string) (必填) Text to translate
默认值: None
$context
(string) (必填) Context information for the translators
默认值: None
$domain
(string) (可选) Domain to retrieve the translated text
默认值: ‘default’
返回值
(string)
Translated context string.
示例
1
2
3
4
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
$translated = _x( ‘Read’, ‘past participle: books I have read’ );
|
Since the string ‘Read’ on its own could have one of several different meanings in English, context is given so that translators know that they should be supplying a short term that means “Books I have read.”
注意
- l10n is an abbreviation for localization.
历史
- 添加于 版本: 2.8.0
源文件
_x() 函数的代码位于 wp-includes/l10n.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Retrieve translated string with gettext context.
*
* Quite a few times, there will be collisions with similar translatable text
* found in more than two places, but with different translated context.
*
* By including the context in the pot file, translators can translate the two
* strings differently.
*
* @since 2.8.0
*
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated context string without pipe.
*/
function _x( $text, $context, $domain = ‘default’ ) {
return translate_with_gettext_context( $text, $context, $domain );
}
|
相关
L10n:
translate(),
__(),
_e(),
_n(),
_x(),
_ex(),
_nx(),
esc_attr__(),
esc_attr_e(),
esc_attr_x(),
esc_html__(),
esc_html_e(),
esc_html_x(),
_n_noop(),
_nx_noop(),
translate_nooped_plural()
- 原文:http://codex.wordpress.org/Function_Reference/_x
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!