Jump to content

Recommended Posts

Posted

Hi everyone!

Can't figure out a problem with my first multi-language website.

I've installed the language modules, created two languages (german (default) and french). I've set up /de/ and /fr/ as paths on the home page.

Of course i filled some content in both languages, but when i switch to french, the path (URL) is correct, but it always displays the default language. 

Can anyone help me? 

Thanks!

Posted

Hi, did you "Activated" the language for each page?

If not:

- Locate the page in the main admin tree.

- Click to "Edit" the page

- Go to "Settings" tab 

- And check the "Active?" checkbox in the right side of the specific language path.

Also remember to set the  $user->language variables (If you are using a link as language switcher).

Posted

:(

Sorry could not help, for me worked out of the box.

Check you installed all required modules

Sound stupid but who knows.....

I have installed:

Languages Support

Languages Support - Fields

Languages Support - Page Names

Languages Support - Tabs

Posted

Do you set $user->language somewhere in your code? Maybe we could help more seeing your template code.

  • Like 2
Posted

Do you set $user->language somewhere in your code? Maybe we could help more seeing your template code.

Hi tpr,

Thanks for this. I can now set the language via $user->language = "fr"; (for instance). But how do I get it automatically?

I'm using this bit of code to switch the language:

foreach($languages as $language) {
if(!$page->viewable($language)) continue; // is page viewable in this language?

$url = $page->localUrl($language); 
$hreflang = $homepage->getLanguageValue($language, 'name'); 
echo "<a style='opacity:0.1' hreflang='$hreflang' href='$url'>$language->title</a></li>";
}

What am i missing? 

Posted

You shouldn't set it manually unless you need a content from a non-current language. I asked if you do set is because if you did your site could show content from other languages.

The language switcher seems OK if it changes the URL. How do you try to echo the content? (where it fails to show the correct language)

  • Like 1
Posted

I find the problem. I had this bit of code in the head that was causing the problem. I deleted it and now it's working. 

    switch ($language){
        case "fr":
            $user->language = $languages->get("fr");
            break;
        default:
            $user->language = $languages->get("default");
            break;
    }

I don't know why i had it there… 

Anyways, thanks for your help!!

Posted

That's why I asked if you set (overwrite) language manually somewhere. Anyway, glad you solved.

  • Like 2

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...