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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2016 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!!