Extracting the key of a translated text programmatically

Hi,

I’m developing a plugin to create a glossary, integrating OJS with the Omeka S Plataform. It’s being built on the context of a major project, which involves translating text to SignWriting.

One of the requirements involves getting the translation key of each text that’s displayed on the UI (say: common.edit for example), which is used as the item identification into the glossary.

I’ve tried to use the PKPLocale::translate hook, but it is only called on missing translation keys, as stated here.

Is there a way to get this translation key? (by some hook, or any other way)

target version: 3.3.0.1

Hi @pablovp,

Calling a hook every time a piece of text is translated would have really high overhead, hence the decision to only call the hook when a translation can’t be found. Instead of hooking in when the translation is looked up, I wonder if you couldn’t instead operate on the level of the locale file, for example hooking into PKPLocale::registerLocaleFile (implemented in lib/pkp/classes/i18n/PKPLocale.inc.php)…

Regards,
Alec Smecher
Public Knowledge Project Team

Understood @asmecher!

I wonder if you couldn’t instead operate on the level of the locale file, for example hooking into PKPLocale:: (implemented in lib/pkp/classes/i18n/PKPLocale.inc.php)…

I don’t think this will solve the problem, since this hook is called on the act of registering a locale file into OJS.

I’ll try to explain the context better, to see if you can help me.

An instance Omeka-S have items, and serves as a glossary. Each of it’s items, are uniquely identified by OJS translation keys (i.e: common.user).

As a Journal Manager focus some text on OJS, the plugin offer’s the option to edit the item on Omeka-S, or create a new one (through it’s API).

So what i need is to mark-up each translated text with it’s key, as the text is displayed into the user interface. This would make it possible for the plugin to extract the key, and pass it to Omeka.

But i didn’t found any hook that i can accomplish something like that.

Hi @pablovp,

Have you seen the Custom Locale Plugin? It’s used to define journal (or press, or server) specific translation overrides without requiring the administrator to modify the locale files. If it’s possible to extract the entire glossary and “install” it as an overlay of the OJS locale files, the same approach may work.

Regards,
Alec Smecher
Public Knowledge Project Team