I'd like to make it possible to reach each language homepage when clicking on language links in the switcher block (which seems logical).
I've just installed and configured a site with three languages (english, french and spanish) and everything is ok with the switcher when I'm on the homepage (I can reach the three homepages directly through the switcher).
Then, if I want to reach one of the two other homepages when visiting another page than the homepage in one of the blocks, the current node id goes behind the language id.
For instance, if I'm on a french page with this URL: http://www.asso-racines.org/welcome/fr/node/12 and if I click on "spanish" in the switcher block, I get : http://www.asso-racines.org/welcome/es/node/12. This page doesn't exist in spanish.
So the current page in french remains displayed (only blocks and banner change language) and can't reach the spanish homepage unless I click on the banner that leads to the default language (english) and then click on the spanish link in the switcher.
I have though created three distinct homepages and entered their respective id in admin/site information.
The menus and banner change language correctly. I just can't unserstand why the links in switcher don't bring back to homepages...
Does anyone have a clue?
Thank you in advance!
Catherine
Comments
Translated pge
Catherine,
I am guess that you have installed i18n module.
If no do it and activate it, you need it to synchronized related language pages.
If yes, did you have define related language pages as "translate" pages :
-activate content type translation
- Synchronize translations
You will see then appears the "TRANSLATE" fonction after the "EDIT" fonction wich let you or create new translated nod eor related existing node between language (cf lower part when you put for example [nid:"number"] in spanish translation of the page you are on.
Pierre
Pierre Orfinger
Schaveyslaan 34
1650 BEERSEL
Belgium
pierre@orfinger.be
+32 475443959
Yes but...
Thanks Pierre for this precious help.
I understand now better how it works.
But in fact, my problem is that the website won't have the same contents in the three languages. It's like if there were three sites in one.
So all I want is that the links in the switcher lead to each language homepage, not more.
I guess I will have to create three language blocks with the real urls for each homepage.
Now my problem is to find out how to add the three diferent flags before each link in each block...
Catherine
My solution doesn't work
In fact, I created three language blocks and then I have the reverse problem: the new language blocks displays only respective homepages but then other blocks don't change language...
I guess there would be some programming to do to tell the switcher to both change the blocks language and display each homepage first...
Links for each home page
Your problem if I understand well is to have related "menu" links in each home page to not translated language document.
You do need that =>
You can create blocks and tells to each specific block that it is for only one language , this selection feature is available as part of multilingual package.
Pierre Orfinger
Schaveyslaan 34
1650 BEERSEL
Belgium
pierre@orfinger.be
+32 475443959
That's what I did
Pierre,
In fact, to sum up:
if I keep that switcher, blocks change language when I click on another language.
The homepage chane only if I am on one of the three homepages.
If I'm on another page, the blocks change language but the page visited (the one I am on) remains.
I added three blocks in the three different languages with links to the three homepagesto replace the switcher block, thinking that this would solve the problem. But then when I'm on another page than the home page, only homepages change language and not the blocks.
If you want to test (the design is so ugly that I'm a little ashamed), You can see the switcher at the top on the left sidebar and the blocks created to sove the problem at the bottom on the left sidebar:
http://www.asso-racines.org/welcome/
Then I came to the conclusion that he only way to have both language changing in blocks plus banner and direct access to homepage per language when clicking on language links in the switcher block would be to tell the system to do both in the switcher block files...
Sorry it's a bit complicated...
The goal is to have three slightly different sites in one rather than one identically translated site.
So the switcher would just have to lead to homepages while changing the whole site language and nothing more (not associating directly one page to its translation)...
Translation process and language swtcher blocks
Catherine,
I am guess you use the language switcher block.
A good analysis of the problematic is shown in
http://www.desk02.be/en/blog/analysis-drupal-language-switcher-block
If you need correct language relation between document you have to pay attention to use the "TRANSLATION" function/editor to relate same document between them (initialized in the drupal "node" table the tnid field to related translate documents between them)
It works then correctly (cf article) but if a document did not exist in a specific language the language switcher did not shown this language anymore.
The only good other solution which will be then to go to the home page for this language but that will need a patch.
The "hook_translation_link_alter()" is also available if some specific process have to be done and the "translation 404" module is available if you need specific process when link to document not existing in the current language is process.
I use it also but with the "active_translation" module which shows all documents int he "best" language available.
Cf site still in development http://www.paniersdelaeken.be.
To test your problem I have modify a previous version of it
http://www.panier.orfinger.net
and take out the active_translation_module.
(! the language icon "-" is for english only use for admin).
You can also look at the site http://www.euractiv.com but where near all articles are at least "partially" (title , abstract) translated.
"Correct" Multilingual site are always tricky, because as explain in the article, you have a lot of available scenarios.
Good luck,
Pierre
Pierre Orfinger
Schaveyslaan 34
1650 BEERSEL
Belgium
pierre@orfinger.be
+32 475443959
Waiting for this help to continue working
Pierre,
about that discussion on http://www.desk02.be/en/blog/analysis-drupal-language-switcher-block
Do you know how to implement language switcher always leading a visitor to the home page in chosen language?
Thnx a lot
Just did this
Hi i just solved this by creating a module which displays a block with the languages exisiting on a Drupal site.
This module does nothing more than linking to the homepages for all the languages.
something like:
$avail_langs = language_list();
$links_sting = '';
foreach ($avail_langs as $lang)
{
$attr = '';
if ($language->language == $lang->language)
{
$attr = 'active';
}
$links_sting .= '<li class="' . $attr . '">' . l($lang->native, $lang->prefix, array('language' => $lang->language, 'attributes' => array('class' => $attr)) ). '</li>';
}
hope this helps a bit
http://www.dertig.nl
Or you could simply...
Or you could simply change one line in the locale_block() method in locale.module (or best, develop a module of your own with this only method and use this block instead of the usual language switcher block - that's what I did indeed!).
The line to change is the following:
$path = drupal_is_front_page() ? '<front>' : $_GET['q'];to change into:
$path = drupal_is_front_page() ? drupal_get_normal_path(variable_get('site_frontpage', 'node')) : $_GET['q'];This way, you don't change the way the block usually works but you make it work for the front page. And if you give URL alias to each of the language front pages, you get an even smoother way to introduce yourself to your visitors!
Hope this still helps.
Best regards,
CYD
Make a hook...
In the template.php file, add This:
<?php
/**
* Implements hook_language_switch_links_alter().
*
* Add a link to home if the translation is not avalaible;.
*/
function mytheme_language_switch_links_alter(array &$links, $type, $path) {
$language_type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) {
}
}