load_default_textdomain()加载默认、经过翻译的本地字符串

目录

描述

译文

加载默认、经过翻译的本地字符串。

从WordPress根目录下的WP_LANG_DIR绝对路径中加载.mo文件。根据本地情况为翻译后的(.mo)文件命名。

原文

Loads default translated strings based on locale.

Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The translated (.mo) file is named based off of the locale.

load_default_textdomain() 描述

用法

<?php load_default_textdomain() ?>

load_default_textdomain() 用法

参数

返回值

(void) 

This function does not return a value.

load_default_textdomain() 返回值

注意

  • l10n is an abbreviation for localization.

load_default_textdomain() 注意

历史

添加于 版本: 1.5.0

load_default_textdomain() 历史

源文件

load_default_textdomain() 函数的代码位于 wp-includes/l10n.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Load default translated strings based on locale.
 *
 * Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
 * The translated (.mo) file is named based on the locale.
 *
 * @see load_textdomain()
 *
 * @since 1.5.0
 *
 * @param string $locale Optional. Locale to load. Default is the value of {@see get_locale()}.
 * @return bool Whether the textdomain was loaded.
 */
function load_default_textdomain( $locale = null ) {
	if ( null === $locale ) {
		$locale = get_locale();
	}

	// Unload previously loaded strings so we can switch translations.
	unload_textdomain( 'default' );

	$return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );

	if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists(  WP_LANG_DIR . "/admin-$locale.mo" ) ) {
		load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
		return $return;
	}

	if ( is_admin() || defined( 'WP_INSTALLING' ) || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {
		load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
	}

	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) )
		load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );

	return $return;
}

load_default_textdomain() 源文件

相关