I'm trying to load a custom language file for a plugins to avoid any changes for this file when updating the plugin. I tried several snippets in the functions.php of the theme, but none of them worked.
add_filter('load_textdomain_mofile', 'custom_load_textdomain_mofile', 10, 2);
function custom_load_textdomain_mofile( $mofile, $domain){
if ($domain == 'my-textdomain')
$mofile = 'path to mo. file';
return $mofile;
}
I tried it with relative and absolute paths and with WP_LANG_DIR. Nothing worked.
Same here:
add_action('load_textdomain', 'load_custom_language_files_for_my_plugin', 10, 2);
function load_custom_language_files_for_my_plugin($domain, $mofile)
{
if ('all-in-one-event-calendar' === $domain && plugin_dir_path($mofile) === WP_PLUGIN_DIR.'/all-in-one-event-calendar/languages/')
{
load_textdomain('all-in-one-event-calendar', WP_LANG_DIR.'/'.$domain.'-'.get_locale().'.mo');
}
}
Both snipptes seem to be pretty ok. However, the MO file is not loaded.
Any help would be appreciated!