返回介绍

translate()

发布于 2017-09-11 10:42:02 字数 2767 浏览 1317 评论 0 收藏 0

translate( string $text,  string $domain = 'default' )

Retrieve the translation of $text.


description

If there is no translation, or the text domain isn’t loaded, the original text is returned.

_Note:_ Don’t use translate() directly, use __() or 相关函数 functions.


参数

$text

(string) (Required) Text to translate.

$domain

(string) (Optional) Text domain. Unique identifier for retrieving translated strings.

Default value: 'default'


返回值

(string) Translated text


源代码

File: wp-includes/l10n.php

function translate( $text, $domain = 'default' ) {
	$translations = get_translations_for_domain( $domain );
	$translation  = $translations->translate( $text );

	/**
	 * Filters text with its translation.
	 *
	 * @since 2.0.11
	 *
	 * @param string $translation  Translated text.
	 * @param string $text         Text to translate.
	 * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
	 */
	return apply_filters( 'gettext', $translation, $text, $domain );
}

更新日志

Versiondescription
2.2.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: get_translations_for_domain()
  • wp-includes/l10n.php: gettext
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/pomo/translations.php: Translations::translate()

Used By

  • wp-admin/includes/plugin.php: _get_plugin_data_markup_translate()
  • wp-admin/includes/import.php: wp_get_popular_importers()
  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: esc_attr__()
  • wp-includes/l10n.php: esc_html__()
  • wp-includes/l10n.php: _e()
  • wp-includes/l10n.php: esc_attr_e()
  • wp-includes/l10n.php: esc_html_e()
  • wp-includes/deprecated.php: _c()
  • wp-includes/deprecated.php: translate_with_context()
  • wp-includes/class-wp-theme.php: WP_Theme::translate_header()
  • wp-includes/functions.php: wp_timezone_choice()
  • Show 7 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文