WordPress函数文档add_user_meta()
检索来自translate()的被翻译过的字符串 描述 译文 检索来自translate()的被翻译过的字符串…
检索来自translate()的被翻译过的字符串
描述
译文
检索来自translate()的被翻译过的字符串
原文
Retrieves the translated string from the translate().
用法
<?php $translated_text = __( $text, $domain ); ?>
参数
$text
(string) (必填) Text to translate
默认值: None
$domain
(string) (可选) Domain to retrieve the translated text
默认值: ‘default’
返回值
(string)
Translated text
示例
Make a string inside your plugin or theme translatable:
1
2
3
4
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
$translated = __( ‘Hello World!’, ‘mytextdomain’ );
|
‘mytextdomain’ needs to be a unique text domain used throughout your plugin/theme. This should always be directly passed as a string literal as shown above, not a string assigned to a variable or constant. E.g., this is incorrect:
1
2
3
4
5
6
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
$text_domain = ‘mytextdomain’;
$string = ‘Hello World!’;
$translated = __( $string, $text_domain );
|
This seems to work, but it will interfere in automatic parsing of your plugin/theme’s files for translation. See these for more information:
- Internationalization: You’re probably doing it wrong – Otto on WordPress
- Translating WordPress Plugins and Themes – Mark Jaquith
注意
- See __() An alias of translate()
- l10n is an abbreviation for localization.
- The function name is two underscores in a row. In some fonts it looks like one long underscore. (Who says programmers don’t have a sense of humor.)
历史
- 添加于 版本: 2.1.0
源文件
__() 函数的代码位于 wp-includes/l10n.php
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* ———————————-
* wordpress函数 kim收集
* ———————————- */
/**
* Retrieve the translation of $text. If there is no translation,
* or the text domain isn’t loaded, the original text is returned.
*
* @since 2.1.0
*
* @param string $text Text to translate.
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
* @return string Translated text.
*/
function __( $text, $domain = ‘default’ ) {
return translate( $text, $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/__
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
评论功能已经关闭!