[OJS 2.4.8.3] Any way to legitimately set UI language based on visitor's country of origin?

I have a multijournal site in which all journals use both Croatian and English for metadata and most use both languages for full-text as well.

My question is: is it possible to set UI’s language to Croatian for all journals if the visitors is coming from Croatia and to set it to English for all journals if the visitor is coming from any other country.

I’ve tried “hacking” my way around it by calling a setlocale URL redirect which worked just fine, but that gave birth to all sorts of problems for Google, which threw almost all pages away and reported redirect errors.

If there’s no way to do this, is it at least possible to have OJS remember the choice for all journals? As it is now, if I change the locale in one journal, the other still remains at its primary locale or the locale I chose there.

Hi @jmvezic,

One option might be to avoid imposing that behavior on the Google crawler, by checking PKPRequest::isBot before doing a redirect. That would permit you to alter behavior as you want for users without affecting indexing crawlers, as long as the bot list (lib/pkp/registry/botAgents.txt) is accurate.

Alternately, you could try implementing this using front-end Javascript, which bots would generally ignore.

Regards,
Alec Smecher
Public Knowledge Project Team

Great, thanks for the quick answer! I’ll try both solutions, but it seems Javascript would work better (and is perhaps a more “transparent” way of doing it). Also, IIRC, Google doesn’t like it when you impose bot-specific behavior on your site, so I’ll try avoiding that.

1 Like