[OJS3.2.1.1] Change locale string via child theme

Hej @asmecher!

I’m trying to change some locales via our child theme, but it does not have any effects. So may I ask some questions:

If I want to change submission.howToCite, submission.howToCite.citationFormats, and submission.outdatedVersion, which regularly reside in submission.po, do I have to set a child submission.po in the ChildTheme/locale/de_DE folder too? Or do I have to add those values to child themes’ locale.po?

Are changes via child theme to locales respected instantly or do I have to clear a specific file in the cache?

Thanks for your help!

@NateWr Can you help me with my problem?

Hello @twa,

Are you using a child based on an existing theme - and if so, which one?

PKP Team

Changes to locale strings will depend on when the locale file is loaded. Since the active theme’s locale file is loaded early, it probably won’t work to override other locale keys except those from the earliest locale file loads (eg - common.po).

Instead, you should use the Custom Locale plugin (from the plugin gallery).

@NateWr Thanks for your explanations, but isn’t this against the logic of a child theme? With a child theme I can overwrite styling, templates, and I’d expect to overwrite translations either.

In older OJS versions this was the way to go and it worked perfectly, so I suspected a bug before posting here. Can you please tell me the logic behind this approach?

I avoided the Custom Locale Plugin in the past, because it was sometimes a little behind the newest OJS release, so we had to wait for the plugin’s upgrade and couldn’t upgrade to the newest OJS release. So up to now, I added translations to the Child theme.

I don’t know how locale files were handled in OJS 2, but in OJS 3 they are loaded on-demand to improve performance. That means not every locale file is loaded at the same time. So if a locale key, example.key, is loaded twice the value in the last file that is loaded will override the value of the previous file.

Since the theme is loaded early in the request handling, it will only overwrite the keys in locale files that were loaded earlier than it. It looks like you may be able to use AppLocale::registerLocaleFile(...) (here) to force your theme’s locale file to the top of the stack, but I’m not sure. I’ve never used it before.