translate() - WordPress 函数参考中文文档

返回介绍

translate()

发布于 2017-09-11 字数2773 浏览 1001 评论 0

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

Retrieve the translation of $text.


描述

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 );
}

更新日志

Version 描述
2.2.0 Introduced.

相关函数

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!