我在.mo
文件夹中有插件wp-content/languages/plugins
翻译文件,我想为特定插件添加自定义翻译,并将.mo
文件放入wp-content/themes/my_theme
文件夹,因此主题文件夹中的新.mo
文件将覆盖插件语言文件夹中的原始.mo
文件。
已解决:translation upgrade safe :
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 ( 'woocommerce' === $domain ) {
$mofile = get_stylesheet_directory() . '/languages/woocommerce-' . get_locale() . '.mo';
}
return $mofile;
}
答案 0 :(得分:0)
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 ( 'woocommerce' === $domain ) {
$mofile = get_stylesheet_directory() . '/languages/woocommerce-' . get_locale() . '.mo';
}
return $mofile;
}