返回介绍

translate_with_gettext_context()

发布于 2017-09-11 10:42:41 字数 2629 浏览 976 评论 0 收藏 0

translate_with_gettext_context( string $text,  string $context,  string $domain = 'default' )

Retrieve the translation of $text in the context defined in $context.


description

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

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


参数

$text

(string) (Required) Text to translate.

$context

(string) (Required) Context information for the translators.

$domain

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

Default value: 'default'


返回值

(string) Translated text on success, original text on failure.


源代码

File: wp-includes/l10n.php

function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
	$translations = get_translations_for_domain( $domain );
	$translation  = $translations->translate( $text, $context );
	/**
	 * Filters text with its translation based on context information.
	 *
	 * @since 2.8.0
	 *
	 * @param string $translation  Translated text.
	 * @param string $text         Text to translate.
	 * @param string $context      Context information for the translators.
	 * @param string $domain       Text domain. Unique identifier for retrieving translated strings.
	 */
	return apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
}

更新日志

Versiondescription
2.8.0Introduced.

相关函数

Uses

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

Used By

  • wp-includes/l10n.php: translate_user_role()
  • wp-includes/l10n.php: _x()
  • wp-includes/l10n.php: esc_attr_x()
  • wp-includes/l10n.php: esc_html_x()

User Contributed Notes

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

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

发布评论

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