OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



How to detect language change

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 http://forum.pkp.sfu.ca

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.

How to detect language change

Postby cjpetrov » Thu Jun 26, 2014 4:32 am

Hello,

I have a questio about how to display different content on the OJS website, when you change your language.

I've tryed:
Code: Select all
{php}
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
switch ($locale){
    case "bg":
      echo "<img src='http:///press.mu-varna.bg/ojs/images/quote_bg.png'/>";
        break;       
    default:
      echo "<img src='http:///press.mu-varna.bg/ojs/images/quote.png'/>";
        break;
}
{/php}


but the problem is that this code detects the browser language.

Regards,
Tsvetan Petrov,
Medical University of Varna Press
cjpetrov
 
Posts: 22
Joined: Tue Apr 15, 2014 9:50 am
Location: Varna, Bulgaria

Re: How to detect language change

Postby asmecher » Thu Jun 26, 2014 8:37 am

Hi Tsvetan,

To get the currently selected language from OJS, use...
Code: Select all
AppLocale::getLocale()
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: How to detect language change

Postby cjpetrov » Mon Jun 30, 2014 12:31 am

thank you asmecher,
i really needed that one :)
cjpetrov
 
Posts: 22
Joined: Tue Apr 15, 2014 9:50 am
Location: Varna, Bulgaria


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron