lenoir Posted May 27, 2016 Share Posted May 27, 2016 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! Link to comment Share on other sites More sharing options...
Francesco Bortolussi Posted May 27, 2016 Share Posted May 27, 2016 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). Link to comment Share on other sites More sharing options...
lenoir Posted May 27, 2016 Author Share Posted May 27, 2016 Hi Francesco, Yes, both languages are activated for each page. Link to comment Share on other sites More sharing options...
Francesco Bortolussi Posted May 27, 2016 Share Posted May 27, 2016 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 Link to comment Share on other sites More sharing options...
tpr Posted May 27, 2016 Share Posted May 27, 2016 Do you set $user->language somewhere in your code? Maybe we could help more seeing your template code. 2 Link to comment Share on other sites More sharing options...
lenoir Posted May 28, 2016 Author Share Posted May 28, 2016 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? Link to comment Share on other sites More sharing options...
tpr Posted May 28, 2016 Share Posted May 28, 2016 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) 1 Link to comment Share on other sites More sharing options...
lenoir Posted May 29, 2016 Author Share Posted May 29, 2016 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!! Link to comment Share on other sites More sharing options...
tpr Posted May 29, 2016 Share Posted May 29, 2016 That's why I asked if you set (overwrite) language manually somewhere. Anyway, glad you solved. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now