OJS 3: Correct procedure for customising messages / locale files

Hello,

i hope it’s okay if i continue on this older topic. At the moment, i’m trying
to modify an OJS 3 theme plugin in such a way that the plugin’s locale
keys overwrite everything else. However, maybe due to my lack of OJS plugin-writing experience
or my rusty PHP knowledge i’m struggeling quite a bit.

So, i registered for the PKPLocale::translate hook in the plugins init method like this:

public function init() {
    $this->setParent('defaultthemeplugin');
    
    ...
    
    HookRegistry::register('PKPLocale::translate', array($this, 'translateCallback'));
}

function translateCallback($hookName, $args) {
    echo "Called!<br>";
    
    ...
}

Initially i would have expected that the is callback invoked for each
string that gets translated. The idea was then, to loop over the plugins
locale files and replace those strings that can be found. But at least in my experiments the callback
seems only to be triggered if no key can be found (that is also my impression
after look at the code of the “translate” method in ‘lib/pkp/classes/i18n/PKPLocale.inc.php’).
Am i missing something and would that be the proper approach anyway?

Thanks in advance.