Codex

Function Reference/load plugin textdomain

Contents

Description

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. The locale is the language code and/or country code you defined in the constant WPLANG in the file wp-config.php. For example, the locale for German is '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 init action.

Usage

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

Parameters

$domain
(string) (required) Unique identifier for retrieving translated strings.
Default: None
$abs_rel_path
(string) (optional) Relative path to ABSPATH of a folder, where the .mo file resides. Deprecated, but still functional until 2.7
Default: false
$plugin_rel_path
(string) (optional) Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path
Default: false

Return Values

(void) 
This function does not return a value.

Examples

function myplugin_init() {
  load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) ); 
}
add_action('init', 'myplugin_init');

Or if you'd like to put language files in a sub folder.

load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

Notes

  • l10n is an abbreviation for localization.

Change Log

  • Since: 1.5.0
  • 2.7.0: '$abs_rel_path' parameter was deprecated.

Source File

load_plugin_textdomain() is located in wp-includes/l10n.php.

Related

Localization: get_locale(), load_default_textdomain(), load_plugin_textdomain(), load_textdomain(), load_theme_textdomain()

See also index of Function Reference and index of Template Tags.