-
-
Save lenamtl/777d59119a57949bdb53b32dc53a90f1 to your computer and use it in GitHub Desktop.
Load a custom translation file from the WP_LANG directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment