Jump to content


Photo

Multilanguages

language

  • Please log in to reply
2 replies to this topic

#1 gottberg

gottberg

    Jr. Member

  • Members
  • PipPip
  • 18 posts
  • 1

  • LocationFinland, Tammisaari

Posted 28 April 2012 - 02:04 PM

Hi, im working on a site that would have default language as swedish with a finnish image flag. Im using this:

if($input->get->language) {
// user clicked on a link to set the language
$name = $sanitizer->pageName($input->get->language);
$language = $languages->get($name);
if($language) $session->language = $language->name;
}
if($session->language) {
// language is defined in user's session
$user->language = $languages->get($session->language);
}

and
<a href='./?language=finnish'>Finnish flag</a>
How do i get the flag to change to a swedish flag?So that when some 1 chooses finnish the finnish flag would become swedish and link to the default page?

I have tried many if cases but didnt get them to work.

Thanks

Simon

#2 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 28 April 2012 - 03:01 PM

So the only thing that's not working is changing the link (and link content), right?

If that's the case and you only have two languages, something as simple as this should do the trick:

<?php
$lang = ( $user->language->name == "finnish" ) ? "default" : "finnish"; 
echo "<a href='./?language={$lang}'>{$lang} flag</a>";


#3 gottberg

gottberg

    Jr. Member

  • Members
  • PipPip
  • 18 posts
  • 1

  • LocationFinland, Tammisaari

Posted 06 May 2012 - 11:36 AM

Thanks for the reply, with flag i meant images but im not getting that to work correctly but the text changed with your suggestion! :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users