load_plugin_textdomain()加载翻译后的插件字符串

目录

描述

译文

加载翻译后的插件字符串。

如果未给出路径,默认路径为插件根目录。.mo文件路径基于带有破折号的域名命名,域名后应跟有一个破折号,破折号后为本地路径。

原文

Loads the plugin's translated strings.

If the path is not given then it will be the root of the plugin directory. The .mo file should be named based on the domain followed by a dash, and then the locale exactly. For example, the locale for German is 'de_DE', and the locale for Danish is 'da_DK'. If your plugin's text domain is "my-plugin" the Danish .mo and.po files should be named "my-plugin-da_DK.mo" and "my-plugin-da_DK.po" Call this function in your plugin as early as the plugins_loaded action.

If you call load_plugin_textdomain multiple times for the same domain, the translations will be merged. If both sets have the same string, the translation from the original value will be taken.

load_plugin_textdomain() 描述

用法

<?php load_plugin_textdomain$domain$abs_rel_path$plugin_rel_path ?>

load_plugin_textdomain() 用法

参数

$domain

(string) (必填) Unique identifier for retrieving translated strings.

默认值: None

$abs_rel_path

(string) (可选) Relative path to ABSPATH of a folder, where the .mo file resides. Deprecated, but still functional until 2.7

默认值: false

$plugin_rel_path

(string) (可选) Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precedence over $abs_rel_path

默认值: false

load_plugin_textdomain() 参数

返回值

boolean 

Returns true if the override_load_textdomain filter returns true or the language file was loaded successfully. Returns false, if the language file could not be loaded (it is not readable or the mo file reader can not understand it).

load_plugin_textdomain() 返回值

示例

This example assumes that it is placed in the main plugin file, or at least a file in the plugin root. If it's not, you'll need to adjust the plugin_dir_path() call accordingly.

load_plugin_textdomain() 示例

注意

  • l10n is an abbreviation for localization.
  • l10n is derived from the 10 letters between the "l" and the "n" of localization.

load_plugin_textdomain() 注意

历史

  • 添加于 版本: 1.5.0
  • 2.7.0: '$abs_rel_path' parameter was deprecated.

load_plugin_textdomain() 历史

源文件

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

load_plugin_textdomain() 源文件

相关