load_muplugin_textdomain

函式
load_muplugin_textdomain ( $domain, $mu_plugin_rel_path = '' )
引數
  • (string) $domain Text domain. Unique identifier for retrieving translated strings.
    Required:
  • (string) $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo file resides. Default empty string.
    Required:
    Default: (empty)
返回值
  • (bool) True when textdomain is successfully loaded, false otherwise.
定義位置
相關方法
load_plugin_textdomainload_default_textdomainload_textdomainload_theme_textdomainload_script_textdomain
引入
3.0.0
棄用
-

load_muplugin_textdomain: 這是WordPress中的一個函式,為一個必須使用的外掛載入翻譯檔案。你可以用這個函式來翻譯你的必用外掛的模板檔案和其他PHP程式碼中的字串。

載入駐留在mu-plugins目錄中的外掛的翻譯字串。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
global $wp_textdomain_registry;
/** This filter is documented in wp-includes/l10n.php */
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
$mofile = $domain . '-' . $locale . '.mo';
// Try to load from the languages directory first.
if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {
return true;
}
$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
$wp_textdomain_registry->set_custom_path( $domain, $path );
return load_textdomain( $domain, $path . '/' . $mofile, $locale );
}
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { /** @var WP_Textdomain_Registry $wp_textdomain_registry */ global $wp_textdomain_registry; /** This filter is documented in wp-includes/l10n.php */ $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); $mofile = $domain . '-' . $locale . '.mo'; // Try to load from the languages directory first. if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) { return true; } $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ); $wp_textdomain_registry->set_custom_path( $domain, $path ); return load_textdomain( $domain, $path . '/' . $mofile, $locale ); }
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
	/** @var WP_Textdomain_Registry $wp_textdomain_registry */
	global $wp_textdomain_registry;

	/** This filter is documented in wp-includes/l10n.php */
	$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );

	$mofile = $domain . '-' . $locale . '.mo';

	// Try to load from the languages directory first.
	if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {
		return true;
	}

	$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );

	$wp_textdomain_registry->set_custom_path( $domain, $path );

	return load_textdomain( $domain, $path . '/' . $mofile, $locale );
}

常見問題

FAQs
檢視更多 >