10

I have a Drupal 7 multi-language(3) website. I have installed the Internationalization (7.x-1.0-beta2) module.

I have created for each language a page, and translate it into two others languages.

Now here is what I want to do: to set a kind of intelligent "front-page" to know what language is selected and set the front page (which I choose) in that language.

How can I do this? I know that in Internationalization module, there is no such kind of thing, am I right? If I set the front page to nothing I get this message: “No front page content has been created yet.” which is normal because Drupal is asking me for one front-page to be set, however I want to have for each language a front-page.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Ek Kosmos
  • 4,050
  • 7
  • 28
  • 45

5 Answers5

35

Might be late to the party with this answer, but after many hours spent trying to solve this myself, I've the following solution.

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 the 'Site information' list tab and check 'Default front page', 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 are currently on, the entire thing, so something like: http://www.example.com/en/admin/config/system/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.

This must be a bug in Drupal, I should get around to opening a ticket. But for now, if someone else comes across this, I hope it solves your problem too.

tanius
  • 7,190
  • 2
  • 36
  • 45
Ben
  • 566
  • 1
  • 6
  • 14
  • 1
    Actually, nowadays the i18n module displays a language switcher at the top of admin pages with localized variables. – nfechner Dec 10 '14 at 09:39
  • Anyone stumbling upon this. As of Sept 2016, these steps still need to be done to a Drupal 7 install just to make it work. I am sure D8 is better/fixed as translation is done differently (but don;t take my word for it). – Nigel Waters Sep 12 '16 at 21:55
4

I've been searching for the same. I 'd like to recommend Drupal 7 - multi-lingual front page node which is complete and works perfectly for Drupal 7 projects.

Kojo
  • 305
  • 9
  • 20
2

After continuing to rip my hair out over this, I found out that this feature is incompatible with anonymous page caching!

Go to /admin/config/development/performance and turn off page caching for anonymous users.

1

May be there is a better way but finally he is how I did.

I have added in template.php the following code:

/**
 * Implements hook_preprocess_page().
 */
function aelius_preprocess_page(&$vars) {
    if ($vars['is_front']) {
        $langcode = $GLOBALS['language']->language;

        if ($langcode == "en") {
            drupal_goto('home');
        } elseif ($langcode == "fr") {
            drupal_goto('accueil');
        }
    }
}
Ek Kosmos
  • 4,050
  • 7
  • 28
  • 45
0

I haven't worked with Drupal 7 i18n yet, but in Drupal 6 you would add a site_frontpage variable to $conf['i18n_variables'] in settings.php and then switch to each language in turn and set the frontpage on the site information page.

Alternatively, you can specify a condition in your theme front-page.tpl.php like so

friendlydrupal
  • 601
  • 5
  • 8