Jump to content

Multilanguages


gottberg
 Share

Recommended Posts

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

Link to comment
Share on other sites

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>";
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...