Ben
Goodyear

Front-end web developer.
Tea drinker. Cheese eater.

Drupal 7: Cracking the multilingual front page nut.

Wow… this has proven to be a popular post. 2 years on and people are still coming here and commenting. Personally I’ve not used Drupal for a while now, so not sure I can help with any problems you might still have. But please check the comments, I continue to publish any ‘current’ useful posts by people, perhaps they might help.

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:

  1. Make sure you have the modules Variable and Variable Translations switched on.
  2. Goto admin/config/regional/i18n/variable
  3. Select ‘Default front page’ from the list, save settings.
  4. 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: http://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.

In closing

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!

48 Comments

explainMe

Thanks, you save my day !

Simon J.

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.

bojan opacak

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.

bojan opacak

damn, I cant see the /regional/i18n/variable options anywhere. :S

Ben Goodyear

@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?

Joolz

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!!!!

Pablo Bravo

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!

Ben Goodyear

@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.

Pablo Bravo

EUREKA! The issue is that i didn’t have activated the module of “Variable example” under the area “Example modules”.

Thanks anyways Ben! Regards!

Ben Goodyear

@pablo Excellent! There is generally always *some* module that needs switching on, glad you got it to work for you!

AnotherDrupalGuy

Thank 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…

Ben Goodyear

@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!

Pol Maresma

One correction on II:
admin/admin/config/regional/i18n/variable
should be
admin/config/regional/i18n/variable

Thank’s for your post.

Ben Goodyear

@pol thanks, corrected.

Dimitris Regginos

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. http://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!

Simon Hoare

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.

Ben Goodyear

@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.

Petabyte

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: http://drupal.org/project/issues/i18n?text=variable&status=All&priorities=All&categories=All&version=All&component=All

Petabyte

Guy

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!

kimlai

Thanks a million !

Jaakko Suojanen

Thanks for saving my day! Luckily i found your site just after ten minutes of wondering the problem.

heckur

Thank you very much, i was about to throw drupal through the window.

Sntig

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!

Tomm

Works! thank you 🙂

Andreas Wileur

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.

Pav

Thanks! Quick, clear, and it works!

Andrew

Dude, you save the day… What a crappy bug.

kuslahne

Excellent tutorial. You helped me a lot with frontpage problem.
Thanks Ben!

Moritz

HI
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

Boris

Thanx! This was really helpful!!!

Ilir

Hello Ben,

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.

Cheers

Dom

Hey Ben,
Thanks for htis tut… 🙂
saved me hours…
Greetings from Germany

Beckys

Thank you! Thank you! Thank you!

Rudi

Yes yes yes yes, IT WORKED !!!! And I only spent 20sec. googling. Thanks for the tip!

nordic material

You’re the go-getter, the nut-cracker and my hero of the day.

Garry

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

Marc

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!

Thanks!

David

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.

Thanks!!

silke

you save my day and night
I had been googeling and testing like a manic.

Thanks so much!!!!!

Diane

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.

Diane

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:
/admin/config/regional/i18n/variable
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

Desmond

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.

Arthur

You saved my day as well ……looking for this solution already for a long time.

Jurgen Beliën

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.

Scot

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.

Samuli

Great post! This was really helpful

Leave a Comment

*
*
*