Hi, I had a problem with the language switcher in the Home Page and now I want to share with you the solution that I applied. After this, my multilanguage website works perfectly (you can have a look at www.tendatech.com).
I installed the internationalization i18 module for two languages (default IT plus EN), then the language switcher block and the language icons (flags). I created tranlation pages for each page of the website, but the language switcher would work fine on every page except the front page.
To translate the front page I needed to click on the footer flag appearing at the bottom of the page, because clicking the language switcher that I placed in the search box region won't work: neither the menus nor the content of the front page would change language. I finally solved it like this:
1. I assigned "path prefix only" to the language settings (for me the the 1st language is IT and the second EN)
2. I assigned the prefix EN for English
3. I created the IT front page (node/16), chose language IT and left the menu link title empty in the primary links
4. I created the EN front page (node/17), chose language EN and left the menu link title empty in the primary links as well
5. In both the IT page and the EN page I checked "promoted to front page" in the publishing options
6. In Administer > Site building > Menus > Primary links, I created a menu item for "Home" and assigned its path to "front", parent item "primary links" and language "all languages"
7. In Site information, I put "node" as default front page
8. The language switcher now works fine: it changes the content from node/16 to node/17 based on selected language and the primary link "Home" always goes to the corresponding front page
Before doing this, I had two primary links going to Home, one for the IT version (node/16) and one for the EN version (node/17), but the language switcher wouldn't change content language on the front page (altough it did it correctly for other pages). To have it in EN I had to use the language link at the bottom of the page body. Now I was also able to hide the language link in the body by going to Administer > Site configuration > Languages > Multilingual system and selecting "Hide content translation links", leaving only the switcher.
Besides, I had a ddbock on my front page which wouldn't show on the EN version, because the theme foresaw it only for the front page and it considered node/17 like a different page. Now I assigned "all languages" to the ddblock and it appears correctly also on the EN front page.
I hope this might be useful to others having the same problem as mine.
Cheers.
Comments
You need to set the same PATH to all home-page translations
Have a look here, it will show you exactly what to do (with screenshots) for setting a front-page that will display correctly per language.
http://drupal-translation.com/node/37
The bottom (per node) language switcher and the sidebar (global) language switchers will work just fine.
internationalization frontpage
Hi,
I had the same issue as described above. This solution resolved my problem.
Thanks a lot for that icanlocalize...
Thanks too!
The post and the link in comment are very useful (I was living a nightmare for hours!), thanks a lot.
Thank you so much
Thanks icanlocalize, I was trying this from last 3 days,
"The path is already in use." error
Not too much of a surprise to find that Drupal won't let me use the same URL path setting for 2 different nodes. Not sure why everyone else seems to have succeeded at this ???
What am I doing wrong ?
Cheers
Dave
Path settings for home page
Hi, you can specify "home" as path setting for the front page in Admin >Site config > Site info > Default front page.
Then you have to create as many "home" aliases as the languages you have in your site: one alias is for the front page node in original language and the others are for the translated versions.
Drupal will allow you to assign the same alias if a node is the translation of another node (i.e. if you created the translation by editing the original node and clicking on "Translate").
Of course, if you create two separate nodes that are not translation-connected , it's impossible to have the same alias for both of them.
Thanks
I'll try it and feedback. I thought my 2 nodes WERE related by translation, but my wife tells me that I have been know to make errors in the past ;-) Unlike her.
Cheers
Dave
Definitely doesn't work for me
I create a new page node with a language of "English" and set the URL path to "home". I save it. I then edit it, click the translate tab and try to add a Spanish translation. If I enter a URL path of "home" the system rejects the form with a "Path already in use error". Definitely. I have tried this with the 6.x-1.0 and 6.x-1.x-dev versions of i18n.
As an aside, and separately causing much hair pulling and gnashing of teeth, my menu items appear and disappear with gay abandon as I work through my simple site, and I have yet to discern a pattern.
Down but not yet out,
Dave
...but this did
Just like everything in Drupal persistence often pays off. I eventually found this rather hard to decipher post http://drupal.org/node/357248 which lead to this comment http://drupal.org/node/313272#comment-1105812 in another lengthy thread. It certainly looked promising so I gave it a whirl and I now have a multilingual front page which switches language correctly using the language switching block.
I can't understand why the previous posts here didn't work for me ?
Cheers
Dave
It might depend on your
It might depend on your translation settings..
Anyway, for me it used to work also if I set Admin > Site info > Front page to "node" and created only one "home" alias for the page in original language that I wanted to be promoted to front page.
Cheers.
Thank you!
It works perfectly for me. I was trying to solve this issue for a week.
Thank you very much!
George
congrats to both!
for sharing solutions to nighmare problems!either of the first ways works fine!u choose what suits u best!
Will Google like this?
This means you have multiple pages under the same URL depending on language context. I wonder if this can get you banned from google? Could be interpreted as cloaking by their crawler.
It's not the same url
It's not the same url for two reasons:
- because you assign a different path alias to each page
- because each page that is not in the default language has a "language prefix" before the path
Google likes it for an additional reason:
- the page content is different because is in another language!
worked perfectly ! tnx
worked perfectly ! tnx steff2009
Some weird thing happend after doing this (i suppose), for some reason the 'en' prefix setting was ignored in the url.
Site configuration / languages / save once again solved the problem :-)
I read some people searched for over a week to solve this, it took me only 15 minutes so i'm a happy guy right now :-)
Another issue :
when using this 'hack', the title is not displayed as it should be (between h1 element)
the edit button is not available and breadcrumb neither...
How did you do the flash on the Front page
Thank you for sharing.
I would like to know how you did the flash on you front page.
Thanks for your advice.
It's not flash
It's Drupal's module Display Dynamic Block. FInd it in the modules list.
Cheers.
thank you
I just wanted to say thank you so much for this post- I have looked through numerous posts on how to fix my multi-language home page-
while I was able to get all the sub pages working, the home page had completely stumped me- your post helped me at the 11th hour for my project- and I got it working!!
thank you!!!
template.php solution
I decided on a PHP solution custom to the site
in template.php
Initially I use the node id for the home page (52 in my case), and then switched to the function drupal_is_front_page().
I doubt this is a better solution, but I prefer it.
function your_theme_preprocess_block(&$vars) {
// fix language switcher for home page
//if (arg(1) == 52) {
if (drupal_is_front_page()) {
if ($vars['block']->module == 'locale') {
if (strstr($vars['block']->content,'href="/"') ) {
$search = array('href="/de"', 'href="/pt-br"', 'href="/es"');
$replace = array('href="/de/startseite"','href="/pt-br/home-pt-br"','href="/es/inicio"');
$vars['block']->content = str_replace($search,$replace,$vars['block']->content);
}
}
}
}
Thanks for the post
your code is working i made some changes for $vars['block']->content change into $vars['content'] in Drupal 7
if(drupal_is_front_page()) {
if ($vars['block']->module == 'locale') {
if (strstr($vars['content'],'href="/"') ) {
$search = array('href="/zh-hans"', 'href="/ko"');
$replace = array('href="/zh-hans/home"','href="/ko/home"');
$vars['content'] = str_replace($search,$replace,$vars['content']);
}
}
}
i want to do multi language(minimum 3 language)
Hi
i want to do multi language(minimum 3 language)....can u please help me how to do..
thx in advance...
By
Gopi
Thanks!
It works for me. Thank you very much!
Drupal 7
Thanks for this post. I forget what I searched for to find it, but it was just the thing.
I was experiencing this in Drupal 7. (Perhaps there's a bug report or discussion about this somewhere?)
For me, the kernel of a clue from this page was that you can get the home page to work as you'd expect by using a View.
I ended up using a View that displayed Fields, so that I could turn off the link to the underlying node. (You also need to add your own filter on language to the View, and might as well add Promoted to the Front Page as well, if you don't use that flag elsewhere).
Christian Nally - B.C., Canada - http://sticksallison.com
D7 language switcher block works everywhere but front page
On D7: I was able to solve this by first making the front page a multi language variable (selectable by language) by going to:
admin/config/regional/i18n/variable and checking default front page.
After that was enabled then the "Default front page" variable in Site Information (at admin/config/system/site-information ) saved different settings for different languages (wait, see edit* below). I chose node/46 for English adn node/49 for German. Now when the language switcher block for german takes me to /de for the path it actually goes to the other node.
edit*: I might be hallucinating but it almost seemed like I had to set the respective language paths for English and German here and here:
http://mydomain.info/en/admin/config/system/site-information
http://mydomain.info/de/admin/config/system/site-information