Hi e2,
That was great. We implemented a derivated solution of yours, but I have a doubt, is that working for you?
Maybe I missed something, but as far as I know, plugins are loaded AFTER locale.php , so It should not find the function osc_runHook.
Our solution is this :
function osc_loadTranslation($dir = __DIR__) {
global $gt,$locale;
if(file_exists($dir.DIRECTORY_SEPARATOR.'translations'.DIRECTORY_SEPARATOR.$locale.'.mo')) {
$file = $dir.DIRECTORY_SEPARATOR.'translations'.DIRECTORY_SEPARATOR.$locale.'.mo';
} else if(file_exists($dir.DIRECTORY_SEPARATOR.'locales'.DIRECTORY_SEPARATOR.$locale.'.mo')) {
$file = $dir.DIRECTORY_SEPARATOR.'locales'.DIRECTORY_SEPARATOR.$locale.'.mo';
} else if(file_exists($dir.DIRECTORY_SEPARATOR.$locale.'.mo')) {
$file = $dir.DIRECTORY_SEPARATOR.$locale.'.mo';
} else {
return false;
}
$streamer = new FileReader($file);
if (isset($gt)) {
$gt->gettext_reader($streamer);
}
}
The you can call it directly after the load of the plugin :
osc_loadTranslation(__DIR__);
We think it's easier for plugin developers to include a one-liner instead of some more. Also, as I commented before, plugins should be being loaded after, I will investigate this (but I don't have a .mo file yet for plugins, so I can not test it) and create a hook for that (but I think that the osc_loadTranslation it's a easy solution.
Thanks!