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
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

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: 18
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: 8668
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: 18
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 3 guests