Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Switching languages. How to make the allocation of the current language?


Go to End


5 Posts   1697 Views

Avatar
WebSpilka

Community Member, 89 Posts

5 June 2008 at 11:24pm

Edited: 05/06/2008 11:29pm

How to make the allocation of the current language?
In Page.ss I have next code

<div id="LangBar">
    <a href="./?lang=ru">РУССКИЙ</a>  <a href="./?lang=en">ENGLISH</a>
  </div>

How I can use Session::get('currentLang'); in Page.ss

in HTML code i wont get next

<div id="LangBar">
    <a href="./?lang=ru" class="Selected">РУССКИЙ</a>  <a href="./?lang=en">ENGLISH</a>
  </div>

Avatar
fdqepd

Community Member, 8 Posts

26 August 2008 at 11:11am

hi, have you found a way of getting th current language?
bye

Avatar
WebSpilka

Community Member, 89 Posts

26 August 2008 at 6:02pm

no ((

Avatar
Willr

Forum Moderator, 5523 Posts

26 August 2008 at 7:34pm

You can get the current language in your php by using - Translatable::current_lang() . If you need it from the template I think you will need to create a function in your PHP code and call it from your template.

in mysite/code/Page.php in the Page_Controller class

function CurrentLang() {
return Translatable::current_lang();
}

Then in your template you can use $CurrentLang, tho I would assume there is some built in method for this...

Avatar
fdqepd

Community Member, 8 Posts

26 August 2008 at 11:58pm

great willr thnks!!