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.

Archive

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

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

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


Reply

5 Posts   1401 Views

Avatar
fiord

5 June 2008 at 11:24pm (Last edited: 5 June 2008 11:29pm), Community Member, 79 Posts

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

26 August 2008 at 11:11am Community Member, 8 Posts

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

Avatar
fiord

26 August 2008 at 6:02pm Community Member, 79 Posts

no ((

Avatar
Willr

26 August 2008 at 7:34pm Forum Moderator, 5511 Posts

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

26 August 2008 at 11:58pm Community Member, 8 Posts

great willr thnks!!