How to force links into specific locales?

Hey all.

I’m the admin of an OCS installation.

Although I’m familiar with PKP and have been playing around before, I’m facing some problems regarding user locales. If I have an account set to English, for example, I manage to set my USER HOME to that language, but any other page will open in the default language (Portuguese). Any tips for fixing this?

Anyway, it would be useful to force links for submission in all languages. For example, I got the URL for the USER HOME in English as: localhost/?conference=index&schedConf=1encontro&page=user&op=setLocale&path[]=en_US&source=%2F%3Fconference%3Dindex%26schedConf%3D1encontro%26page%3Duser

It does the trick in order to open the English (or Spanish, etc) version of the USER HOME, but couldn’t use this for the submission page. I’m guessing it is because the “op=*” param needs to be used “twice” (for both “setLocale” & “submit”), but I can’t figure out the right way (always get 404 error in my tries).

Should I call “op=” only once? If so, how to combine submit & setLocale in the URL?

Thanks in advance,
Thiago Cavalcanti

Anybody? Been trying but nothing yet.

Hi @Thiago,

The op can only be specified once, but you can use the source parameter to tell the setLocale operation where to redirect the user after the locale has been set.

Alec Smecher
Public Knowledge Project Team

Hi @asmecher ,

Thanks for your answer!

I’m sorry to say but I’m on the exactly same page here, your quick answer was not helpful, as I was already working with source parameter from the start, even before posting here.

Did you see that I’m trying to call a page that needs the op to be called, but that I also need to call op=setLocale?

I don’t know any other way to call this page with my desired locale.

I’ve tried to put this op=submit in the full path after “source=”, but got 404 error again.

Please help:

How can I call BOTH “op=setLocale” and “page=author&op=submit”, if I can’t call “op=” twice?

I’ve been trying several combinations and playing around with the source parameter as you suggested, but I need this specific information, any generic answer won’t do the trick because I’m aware of the I should call the source parameter.

I’ve already tested it. It just doesn’t work adding an “%26page%3Dauthor%26op%3Dsubmit” in the final of source parameter, what seems to be the actual solution following you suggestion.

Sometimes I manage to get redirected there, BUT always in the default locale and NOT in the locale specified through setLocale.

Thanks in advance,

Hi @Thiago,

Could you post the full URLs you’re trying? It would be useful to have both the one that works, and one or two of the ones that don’t. It’s fine if these are localhost URLs (and if they aren’t, feel free to obscure the domain name).

It looks like you’re using disable_path_info in – this results in much uglier URLs. If it’s possible, I would suggest turning off that option.

Alec Smecher
Public Knowledge Project Team

Thanks, @asmecher !

I’m aware that the url is in “ugly mode” heheheee. but can’t work on it for now, it was decided to get back to that just before future conferences.

But if you have any easy guide for taking “ugly mode” off WITH NGINX, please share this information, I would make it another try. When I was trying to get ride of the “ugly mode”, any link was redirecting to home page, so I’ve decided to put this aside for a while…

Let me show now some links (I’ll link the IP of my server this time so you can try to make any tests).

For example, the following link works like a charm, opening the locale es_ES as required:[]=es_ES&source=%2F%3Fconference%3Dindex%26schedConf%3D1encontro%26page%3Duser

(it’s a link for the user home, but as you are not registered you’ll see a login page with the es_ES locale anyway, right?)

Now, this seems to work right away for any page, BUT the pages that need to call “op=”, which is the case for the submit page as I said before.

For example, try the following link:

If you read the params, I tried to call the submit page only through the source parameter, as you seem to have suggested. It opens the page, but NOT in the desired locale (en_US in this case), rather using the default pt_BR. Here is the problem. This is the best result I could get so far, because other combinations result in 404 error. I’ve tried many ways to write the params in order to fix it and make it work, but couldn’t get it to work yet. This was the closest I got to find a solution, but lacks a proper setLocale.

I’m still convinced this problem may be because “op=” is asked for opening some specific pages, but also needs to be called to setLocale. That’s why I was trying to direct the question this way from the start, because I think proper handling op for both operations (opening the desired page and setting the specific locale at the same time) is the solution.

Thank you,

Hi @Thiago,

Off the top of my head, the approach you’re using should work. The way the setLocale/source interaction works is as follows:

  • The setLocale operation is requested. This is implemented in pages/user/ It sets the user’s currentLocale session variable to the requested session.
  • After storing the desired locale, it looks for a source request parameter and redirects the user to it. (This is provided as a URL parameter, hence the need for special characters in it to be urldecoded.)

If you’re seeing the redirect you expect, but the locale doesn’t seem to be getting set, I wonder if one of the checks in the setLocale function to ensure that it’s a valid locale somehow aren’t getting passed. This would result in the new locale not getting stored, but the redirect happening as requested.

If I were debugging this, I’d add some error_log calls to the setLocale function to dump out conditions it’s getting called with and ensure that e.g. the setSessionVar function is being called.

Alec Smecher
Public Knowledge Project Team

Thanks, @asmecher

I was pretty sure the approach was right (or almost) because of the tests I’ve made, including pages that don’t need to call “op=” for opening.

As you can test for yourself, although the approach seems to be right, it’s not working.

I’ll try to investigate further starting from your comments, thank you very much.