Drupal 7 - multi-lingual front page node

  • Posted on: 28 July 2011
  • By: Julia

Drupal 7's internationalization modules seem to work great, with only one small problem ....

Everything is working fine except your front page steadfastly refuses to be in more than one language.

If you want to use a node as your front page (rather than a content feed), and you want to be able to switch languages for that home page node, then you need a couple of tweaks.  This was also an issue with Drupal 6 and there are lots of cries for help and fixes out there for Drupal 6. 

A drupal 7 search is a little less forthcoming, as you're likely to be swamped by the Drupal 6 results, at the end of which you'd find a fix by editing settings.php. Drupal 7 lets you set the multilingual variables via the interface, there is even a simple how to on Drupal.org, however its a bit brief (and makes more sense if you've trawled through all the other Drupal 6 stuff), so here's a slightly more expansive step by step.

We're assuming you've got Drupal 7 + Internationalization (i18n).

  • Firstly, every language doesn't need a prefix.  This still works if the default language has no prefix. However alternative languages all need prefixes specified in Configuration > Regional and Language > Languages.
  • Make sure you've enabled Multilingual Support in the Publishing Options of your content type (eg. basic page), any way this must be enabled for any content type you wish to have translations for.  To do this go to Structure > Content Types > Basic Page, go to Publishing Options and enable 'Enabled, with translation'.
  • You create your node and a translation of that node (if the nodes already exist the 'Translate' tab on Edit Content allows you to specify an existing node.
  • Set the URL Path Settings of both nodes by giving an alias of 'home' - do this for both nodes, you are allowed to do this because the translated node will automatically be assigned a prefix.  eg.  the default language home page will be: www.mysite.com/home, the French translation of the home page will be www.mysite.com/fr/home.
  • In Modules enable the Variable Translation module (this is included in the internationalization modules) and the other modules it depends on.
  • Go to Configuration > Regional and Language > Multilingual Settings and click on the 'Variables' tab.
  • Check 'Default Front Page' and commit.
  • Use the language switcher block and ensure you're switched to the default language.
  • Go to Configuration > System > Site Information and set the Default Front Page to 'home' (no apostrophes!) and commit.
  • At the top of the Configuration > System > Site Information page there is a language switcher, use it to switch to each of your alternate languages in turn, repeating the step above for each one, remembering to commit each time.  You will note that when you change language the prefix is added to the URL preceding the default front page.

Et voila!

Front page perfect (Acceuil parfait - sounds like a dessert ...)

ps. as an extra bonus go through a similar process with other variables - enable the appropriate variable, then configure eg. the site slogan, set emails etc per language too.

Originally published by the same author on Cybersundae.com