Last active
August 29, 2015 14:07
-
-
Save tormjens/ac9adbdf83e23375f27f to your computer and use it in GitHub Desktop.
Replaces a .mo-file based on a text domain. In this case from within a theme. Two different methods. One replacing the plugin text domain all together, and one that just switches the .mo-file.
This file contains 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
add_action( 'after_setup_theme', 'myplugin_load_textdomain' ); | |
function myplugin_load_textdomain() { | |
load_plugin_textdomain( 'my-plugin', false, get_template_directory() . '/my-plugin-lang-dir-in-theme/' ); | |
} |
This file contains 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
add_filter( 'load_textdomain_mofile', 'myplugin_new_mo', 20, 2 ); | |
function myplugin_new_mo($mo, $domain) { | |
if( $domain === 'my-plugin-textdomain' ) { | |
$dir = get_template_directory() . '/my-plugin-lang-dir-in-theme/'; | |
$mo = $dir . 'coolfile.mo'; | |
} | |
return $mo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment