How to provide unique URL for diferent language localization

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 5
Joined: Thu Feb 07, 2013 1:02 pm

How to provide unique URL for diferent language localization

Postby radap » Thu Feb 07, 2013 2:53 pm


Our journal ( publish paper on three languages Ukrainian, Russian and English, because we use in OJS three localization. But search engines could index only one localization that by default.

I found that in head tag there is metadatas on three languages, but it seems that only google scolar recognize their, rest of engines (include common google) not pick up this metedata.

Is it possible to provide unique URL for different language localization? May be by use mod_rewrite

Thanks a lot,

Posts: 32
Joined: Tue Jun 11, 2013 1:12 pm

Re: How to provide unique URL for diferent language localiza

Postby angevent » Mon Jul 22, 2013 3:18 am

Up :)

Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: How to provide unique URL for diferent language localiza

Postby asmecher » Mon Jul 29, 2013 2:26 pm

Hi all,

See There's a couple of patches linked there that will permit a "uiLocale" URL parameter to override the locale for any page. You can use mod_rewrite to affix that parameter to URLs going into OJS according to whatever scheme you like.

Alec Smecher
Public Knowledge Project Team

Posts: 18
Joined: Tue Oct 29, 2013 10:06 am

Re: How to provide unique URL for diferent language localiza

Postby Looted » Thu Mar 20, 2014 5:17 pm

I have a problem with the patches provided:
In the github version

Code: Select all

$locale = Request::getUserVar('uiLocale');
   if (empty($locale) || !in_array($locale, array_keys(AppLocale::getSupportedLocales()))) $locale = Request::getCookieVar('currentLocale');
   } else {
   $sessionManager =& SessionManager::getManager();
   $session =& $sessionManager->getUserSession();
   $locale = Request::getUserVar('setLocale');

the uiLocale parameter does not work at all (appending it to url doesn't change the language). When I put $locale = Request::getUserVar('uiLocale') after $locale = Request::getUserVar('setLocale') it does work. However, it breaks the language toggle (changing language in the toggle does nothing). Is this supposed to work like that? I want to provide URLs for different language versions (especially that Google Scholar indexes resources in one language only), but with provided solution, when someone gets to the page using the link with additional language parameter, he won't be able to change the language.

Posts: 18
Joined: Tue Oct 29, 2013 10:06 am

Re: How to provide unique URL for diferent language localiza

Postby Looted » Fri Mar 21, 2014 6:34 am

I did work out a solution to the problem:

Code: Select all

if ($session->getSessionVar('currentLocale')) {
$locale = $session->getSessionVar('currentLocale');
else {
if (Request::getUserVar('uiLocale')){
$locale = Request::getUserVar('uiLocale');}

Now the uiLocale parameter decides what is the page locale, but it is overwritten when a user changes locale using the language toggle. As long as user doesn't touch the toggle (or session expires), the uiLocale parameter works. Now I have a single question, maybe someone know the answer: do bots use sessions or click on the forms (like language toggle)? The problem so far was, that bots indexed my page only in default locale (english), which led to a serious problem in Google Scholar - polish articles god indexed with their english titles, and now Google doesn't count the citations in their original title (they appear as having no citations).
My idea of resolving a problem was initially adding a rule, that metadata is generated in the original language (not the site current locale), but it isn't a perfect solution (normal google still indexes either polish, or english page, not both). So came the idea of generating language specific links, so the bots could index both. The original solution, pushed to github, broke the language toggle block, so while the bots would get both the versions of the article, the user following that link wouldn't be able to change language.
I think such functinality is an important area that needs improvement in OJS for multilangual journals - so that the site gets indexed in all supplied languages, and not only the default one. Classic Google search does even support such translation parameters in webmaster tools; Google Scholar doesn't, so it's even more important to provide multiple links for each version. If anyone has any idea on how to approach the issue with indexing, I'd be glad to hear it.

Return to “OJS Development”

Who is online

Users browsing this forum: No registered users and 2 guests