Drupal 7: Cracking the multilingual front page nut.
You’re probably here because you’ve the delightful task of creating a multilingual Drupal 7 installation.
Things have been going OK, you downloaded and installed i18n, switched some translation modules on and happily started inputting content and adding translations. You figured it was time to created some front pages, of course a separate one for each language, otherwise what’s the point. You figure it’s as easy as creating and translating other nodes, so you do that, set the default front page, take a look, switch the language and…. it doesn’t work!
Here is where I save the rest of the day from Googling
You’ve probably already come across mention of the default front page setting in admin > configuration > system > site information. I read plenty of things about this, basically saying here is where you can set multiple default front pages depending on languages. However, what seemed to be missing, at least for me was a proper explanation of how to get it working.
So, here we are, for Drupal 7:
- Make sure you have the modules Variable and Variable Translations switched on.
- Goto admin/config/regional/i18n/variable
- Select ‘Default front page’ from the list, save settings.
- Goto admin/config/system/site-information, you’ll notice a block of text there saying something about some of your settings being multilingual variables and a list of links for the languages you are running which allow you to set the settings for each language.
Now, this is where the real GOTCHA comes up… clicking those links and changing the settings does nothing. Your left with the same settings still for all languages. The way around this?
Check the URL you currently on, the entire thing, so something like: www.mysite.com/en/admin/config/site-information/
Notice the language prefix there before /admin? To change the settings for the other languages you want to use, switch the prefix in the URL and then make your changes. And now, as if by magic, multiple front pages, properly changing based on language.
I think, but haven’t checked, that this behaviour might be result of having the admin side in multiple languages. I didn’t see what I had mine set as, or if it were possible to force it to one language only. But my belief is, if you can drop the language prefix from the url the switching of languages on the settings page might have an effect.
I’ve also had similar problems using the node reference url widget on a content type. If the prefix in the URL doesn’t match that of the language of the content I’m editing, either the wrong nodes are listed as reference options or I can’t edit a previously chosen value.
So, beware of the language prefix in the URL when dealing with a multilanguage Drupal install. It might be something worth checking if you’re having problems.
Lastly, if you found this useful please spread the word or up vote this answer on Stack Overflow where I originally posted the answer, albeit much shorter than this!
Thanks, you save my day !
Thank you. It works! 🙂
Thanks a million. This saved me from going bald. The root issue for this (and other similar things Drupal is absolutely swarming with) is that Drupal is helplessly outdated considering such taken-for-granted out-of-the-box features as multilingual support and a decent access control.
I will try this now, and if it works, you have a beer. I am writing now though because of the I SOLVED IT mindset which will keep me from thanking you later.
damn, I cant see the /regional/i18n/variable options anywhere. :S
@bojan well it has been a while since I did this, but do you have the correct modules installed? Mainly thinking do you have the variable module installed?
You rock… Spent the better part of 2 days trying to figure out how to specify the correct front page per language… Was about to do some funky workaround… This was such an easy solution! THANK YOU FOR POSTING!!!!
Hello Ben! Would you plese help me? I was serching on the internet for the solution but can’t figure this out. I have the same situation that Bojan, i already re-checked that i have “Variable” installed and i do, with all it’s options active and still i can’t see the Variable option.
Thanks in advance for the support!
@pablo as I said to @bojan, it has been a while since I did this. You’ve checked you have the variable module on, did you also check you have variable translations on? Without setting up an install of my own to test, I can’t be of much more help.
EUREKA! The issue is that i didn’t have activated the module of “Variable example” under the area “Example modules”.
Thanks anyways Ben! Regards!
@pablo Excellent! There is generally always *some* module that needs switching on, glad you got it to work for you!
In addition to this, some may run into another issue where pasting in the alias for each home page results in a “no such page” error. If you are inserting the language prefix into the URL as this article suggests, a bug causes the default front page field to be displayed without a trailing slash after the language prefix. Add the alias without a slash and it will save. Apparently the slash is prepended to the value when saved, it’s just not displayed to the left of the field indicating as such.
If you try adding aliases as front pages without adding the prefix to the URL you may get the “no such page” here too. The only solution I found was to actually use the node ID such as “node/7.”
You’d think after 11 months that someone would have fixed this problem in core or the relevant modules. Surely the responsible parties are aware…
@AnotherDrupalGuy thanks for the extra info, always helpful to have it. Indeed, it would be nice to think it had been updated/fixed. I think they are aware of it and no doubt it has been fixed for D8, I seem to recall coming across a related issue. Unfortunately we’re left waiting for a back port to D7 to come, if it ever does!
One correction on II:
Thank’s for your post.
@pol thanks, corrected.
Since you are so helpfull, can you help me with another multilingual D7 issue? I have lost many hours and nerves searching a solution, but the only thing I found was unanswered posts with the same question as mine (e.g. drupal.org/node/1649170). Well, in short: My site has to be n languages with every page showing up in every one of those n languages. I made an installation, enabled all the nessesary multilingual related modules, took the nessesary steps towards multilingual, put some content, translated it in all the languages. Everything seems to work fine (switching language switches the page’s language), exept one thing: the main menu shows ALL links. Every page has a link there in all n languages!
Thanks! Your hint saved me a lot of time. It also helped me to understand Drupal logic a bit better.
Perhaps someone should rewrite the Drupal multilingual manual from the point of “use case” scenarios, since there can only realistically be a handful of these. Then there could be a list of set-up steps for each of these.
@dimitris I don’t know why, but one of the common ways to deal with this is by creating n different main menus, with each set to a specific language. That way, only one of those menus will show, the one which is that current language. I know I’ve done that in the past.
It didn’t saved me from going bald like some others but it saved my day !! Thanks very much!
Also for point iv, if you use language codes as subdomains like me, replace en.mysite.com/admin/config/site-information/ with www.mysite.com/en/admin/config/site-information/
Thank you Ben 🙂
Yeehaa! I already smelled something fishy when I noticed that clicking the different language links didn’t change anything and mentally already prepared to dissect the database tables … but then your article crossed my eyes.
I think this is a bug, so maybe someone should file an issue on the i18n project site when it doesnt exist yet. I’m in a hurry but at first glance I couldn’t sight a matching issue: drupal.org/project/issues/i18n?text=variable&status=All&priorities=All&categories=All&version=All&component=All
Ben, many thanks! You put me on the right track. After first following another tutorial not all of my necassary modules weren’t ‘on’. You completed the picture of how it works. And now it works!
Thanks a million !
Thanks for saving my day! Luckily i found your site just after ten minutes of wondering the problem.
Thank you very much, i was about to throw drupal through the window.
THANKS!!! I’ve been trying to find a solution to this problem for days! I even posted a message on the French Drupal forum.; now I added a link to your page there, in case someone else needs it. Thanks again!
Works! thank you 🙂
Thanks this solved my problem!
I tried adding URL prefixing, which works. But that made my URLs look ugly (something /en/?language=sv …) so I disabled it again and found that the important thing is just to use the correct language when setting the front page. I have enabled language icons in the admin too.
Thanks! Quick, clear, and it works!
Dude, you save the day… What a crappy bug.
Excellent tutorial. You helped me a lot with frontpage problem.
THANK YOU VERY MUCH
I’m german and I checked everey forum and there was nothing. therefore i tried my english skills and now… you made my day. even if the new day has startet and i googled your blog about 4 hours 😀
but thank you perfekt description.
I have another “small” problem. My Forum containers are translatet. The Problem is that the German Containers are full with topics but the “other language” is translated (yay) but the containers are empty. I need there the German container content with “the other” language topics.
Would be nice if you or somebody have an idea. Thank you
Thanx! This was really helpful!!!
Thanks a lot for this! It’s been ages I’ve been looking for a “clean” solution for doing this! And here it is 🙂
Thanks again for this tutorial.
Thanks for htis tut… 🙂
saved me hours…
Greetings from Germany
Thank you! Thank you! Thank you!
Yes yes yes yes, IT WORKED !!!! And I only spent 20sec. googling. Thanks for the tip!
You’re the go-getter, the nut-cracker and my hero of the day.
I have done absolutely everything in this but it still isn’t working for me. I have a default language of english and german as my alternative. If I go to visual5d.com and try to swap language then it just redirects to visual5d.com/de and no changes happen. The only time it works is if the home page path is used visual5d.com/home – if I try to change language then it works fine. Is there a way around this? Im using latest versions of the modules
Thank you very very much!!!
I was going arround with Variables to change it for work, but then i had the problem with the Meta Tags on the Mainpage.
Your way works perfekt!
Drupal 7 & Marinelli Theme case:
This helped to find out my problem, everything was ok till the part where I have to edit the language in order to edit multilingual homepage, I had to use URL with NODE/NUMBER, using different url names wont work for multilingual homepages in my case.
you save my day and night
I had been googeling and testing like a manic.
Thanks so much!!!!!
Sorry to say. I’ve got a live site for which every page is translated into 4 languages. I’m getting ready to go live with the translations, and using language switcher dropdown module. I mention the module because it is enabled, not because the problem shows up specifically there.
I use your magic nutcracker trick and enter the page name for the home page for Spanish, having added “es/” before the “admin/” in the URL.
This changed the URL for English home page as well. So I went back to the original admin page and changed it back for the English home page.
Then I returned to the admin page, putting “es/” before “admin/” and also clicking the “Spanish” link in the row of variables. Tried again. Still changed the default (English) to the new URL.
So apparently the magic bullet is no longer working.. or… maybe I have a module conflict that is preventing it … or… maybe there’s yet another module I didn’t notice needing enabling?
Thanks for any clues from the peanut gallery.
Updating my comment above. (and celebrating success)
I’m using the dev version of the language switcher dropdown module, which is new as of October 1, 2013.
I navigated to this admin screen:
I did not have this box checked, but I needed to check it, and now all works, even without the fancy workaround!
[ X ] Default front page
The Gotcha you mention isn’t I think a gotcha. The url prefix /en/, /it/ etc changes if you just choose that language in the language menu before you go to the admin pages. This makes sense from the user point of view, even if it takes a blog post to explain it ;-). To set the home page for Italian, first choose the Italian language. Like a lot of Drupal settings conundra there’s a programmer not a user logic to it.
You saved my day as well ……looking for this solution already for a long time.
For anyone stumbling upon this, another way of authoring these variables is to use of the Variable UI module. It is part of the Variable module.
I may be showing my stupidity here, but I kept entering node/1 (English) as the home page node, thinking in the background it was still node/1 just a different version of that when I realized that my Spanish and Chinese versions were node/2 and node/3 respectively. Duh.
Great post! This was really helpful