WooCommerce::load_plugin_textdomain
Load Localisation files.
Note: the first-loaded translation file overrides any following ones if the same translation is present.
Locales found in:
- WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo
Method of the class: WooCommerce{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WooCommerce = new WooCommerce(); $WooCommerce->load_plugin_textdomain();
WooCommerce::load_plugin_textdomain() WooCommerce::load plugin textdomain code WC 10.7.0
public function load_plugin_textdomain() {
/**
* Filter to adjust the WooCommerce locale to use for translations.
*/
$locale = apply_filters( 'plugin_locale', determine_locale(), 'woocommerce' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingSinceComment
$custom_translation_path = WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo';
$plugin_translation_path = WP_LANG_DIR . '/plugins/woocommerce-' . $locale . '.mo';
// If a custom translation exists (by default it will not, as it is not a standard WordPress convention)
// we unload the existing translation, then essentially layer the custom translation on top of the canonical
// translation. Otherwise, we simply step back and let WP manage things.
if ( is_readable( $custom_translation_path ) ) {
unload_textdomain( 'woocommerce' );
load_textdomain( 'woocommerce', $custom_translation_path );
load_textdomain( 'woocommerce', $plugin_translation_path );
}
}