woocommerce/docs/code-snippets/making_translations_upgrade...

1.1 KiB

post_title menu_title tags current wccom url
Making your translation upgrade safe Translation upgrade safety code-snippet https://woocommerce.com/document/woocommerce-localization/#making-your-translation-upgrade-safe

Like all other plugins, WooCommerce keeps translations in wp-content/languages/plugins.

However, if you want to include a custom translation, you can add them to wp-content/languages/woocommerce, or you can use a snippet to load a custom translation stored elsewhere:

// Code to be placed in functions.php of your theme or a custom plugin file.
add_filter( 'load_textdomain_mofile', 'load_custom_plugin_translation_file', 10, 2 );

/*
 * Replace 'textdomain' with your plugin's textdomain. e.g. 'woocommerce'. 
 * File to be named, for example, yourtranslationfile-en_GB.mo
 * File to be placed, for example, wp-content/lanaguages/textdomain/yourtranslationfile-en_GB.mo
 */
function load_custom_plugin_translation_file( $mofile, $domain ) {
  if ( 'textdomain' === $domain ) {
    $mofile = WP_LANG_DIR . '/textdomain/yourtranslationfile-' . get_locale() . '.mo';
  }
  return $mofile;
}