Translate Drupal front page (i18n)

tags: Drupal   php snippets  
drupal tags: translations   i18n  
If you're using the i18n module to translate a website's contents, and you need also to have a specific homepage for each language, here are a couple of ways to get it:

if you use a custom PHPTemplate front page (page-front.tpl.php

you can call the node of the translation corresponding to the language actually in use:
<?php
if (i18n_get_lang() == 'it') {
    print
node_view(node_load(array('nid' => 18)), 1);
}
elseif (
i18n_get_lang() == 'en') {
    print
node_view(node_load(array('nid' => 19)), 1);
}   
?>

if you use the default Drupal homepage (/node)

  1. set the alias of the main translation node (ie: home) as the homepage in the webiste settings (/admin/settings/site-information)
  2. set the aliases of each following translation nodes to /en/home, /fr/home, and so on.

Similar:

thanks

It helps me a lot! Thanks a lot !

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <h3> <h4> <img> <hr>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Are you human (question to prevent spam)?
Twitter
Add to Technorati Favorites

Featured:

Archives

March 2010
SunMonTueWedThuFriSat
123456
78910111213
14151617181920
21222324252627
28293031
PureDivs Drupal Themes Conversions