Advertisements

load_plugin_textdomain

Definition:
function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) {}

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 with a dash, and then the locale exactly.

Parameters

  • string $domain: Unique identifier for retrieving translated strings
  • string $abs_rel_path: Optional. Relative path to ABSPATH of a folder, where the .mo file resides. Deprecated, but still functional until 2.7
  • string $plugin_rel_path: Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precedence over $abs_rel_path

Defined filters

  • plugin_locale
    apply_filters( 'plugin_locale', get_locale()

Source code

function load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) {

	$locale = apply_filters( 'plugin_locale', get_locale(), $domain );



	if ( false !== $plugin_rel_path	) {

		$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );

	} else if ( false !== $abs_rel_path ) {

		_deprecated_argument( __FUNCTION__, '2.7' );

		$path = ABSPATH . trim( $abs_rel_path, '/' );

	} else {

		$path = WP_PLUGIN_DIR;

	}



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

	return load_textdomain( $domain, $mofile );

}

2287

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: