Hi,
I create a page A with language=german and a menu entry A.
Then I create page B with lang=german and a menu entry B. I create a translation for this page with a menu entry B-eng.
Third, I create a page C with lang=neutral and a menu entry C.

Now, when I'm at page B with german language and switch the language with the flags in the global language switcher block, the page B switches to english content and the menu entry "A" disappears. I Just have B-eng and C in the menu. This works as I expect it.

But when I'm at the lang-neutral page C and klick on the english flag in the language switcher block, nothing changes. Of course C stays because it is lang neutral, but menu entry A does not disappear!

Is that a bug or by design? I would expect all german-only pages/menus to disappear whenever I click on the english flag in the switcher block and not only when I'm on a page that has a translation. Otherwise the global language switcher block doesn't make much sense because it only has effect on pages where I have per-page flags either (i.e. when a translation exists).

cu,
Frank

Comments

Anonymous’s picture

Ok, this was partly my fault because of a wrong setting in the Site Configuration/Multilingual System! I set this now to "Current language and no language" and now the german pages disappear when I click on the english flag and vice versa!

But not always! Here's the remaining problem explained better I hope:

Step 1:
I click on the german flag in the language switcher. Now my menu is:
A
B
C

C show a language neutral page, A is german without translation, B is english with english translation "B-eng".

Step 2:
I click on C and watch the page C. Now I click on the english flag in the language switcher block. My menu becomes

B-Eng
C

Thats fine!

Step 3:
Now I switch back to german and click on A, i.e. I watch the german page A and have menu
A
B
C

Step 4:
While wachting page A, I click on the english flag again. Now nothing changes. My menu still is
A
B
C
but the path changes from http://bla/node/31 to http://bla/en/node/31, although still showing the german page A.

Step 5:
Now I click on C. And at this moment, the menu changes to
B-Eng
C

I think this is not a good solution. I understand that in Step 4 drupal keeps showing page A, because there is no english translation of it and instead of showing a 404 error or sth. it keeps showing the german page.

BUT in step 4 the menu should change immediately when clicking on the english flag. That should not be delayed until I click on menu entry C in step 5.

AaronCollier’s picture

I don't think you need to have as many steps as this. I have the same problem. All it takes is one step.

Go to any page that is in English but not in Czech. Click on the Czech button. All content that can be translated is, all content that is only Czech appears in the menu.

But the menu will continue to show all only-English items. I think it's related to the same problem of keeping the only-English page there, and not displaying a 404 page.

Anonymous’s picture

I guess thats not the same behaviour. When I'm at a page that is only in English and not in German and click on the german flag, nothing changes. Not even the menu. It stays all the same with all english-only entries. Only when I then click on the menu at a page that has both languages, then all of a sudden the menu switches all its entries from english to german.

Your problem that after clicking on the Czech button you get the Czech-only menu items, but the English-only items also remain in the menu, is likely related to the settings. Go to Site Configuration/Multilingual System and chose "Current language and no language". Then you will only have either the Czech-only or the English-only menue entries.

But my problem is that the menu doesn't change when I click on the language flag while I'm at a page that has a language but no translation to the other language.

AaronCollier’s picture

I have selected "current language and no language" (actually "only current language and no language"). That is what I get when I click on a page that is both English and Czech.

The rest of the menu doesn't change when I am on a page that isn't in that language, which I believe is exactly what you are describing. If you had things that were only in English you would see what I meant.

You only need one step for it, and I think it's the same as not displaying a 404 page.

Anonymous’s picture

Hmm, the behaviour here has indeed changed. After I configured a lot and reinstalled the i18n module for other reasons, it behaves exactly as you describe which is still different from what I was seeing before.
I think it would be a nice feature for i18n if one could define a default error page that is in the language for which no translation exists and would show sth. like

"There is no translation for this page yet. Please create a translation of set the page to "language neutral" to view it with the current language selection"

If such a page existed and was linked from the language flag, the menu would switch the right way, just like if a translation existed. And such a page would be helpful also, I guess.

AaronCollier’s picture

Title: Menu visibility with language-mixed pages » Page to Show Lack of Translation
Category: support » feature

That might be a useful thing to have. I have now idea how easy it would be to implement. You'd have to have separate ones for each language, I assume.

Anonymous’s picture

I guess it should not be that hard. I was able to hack that into my own little language switcher block that I created to show switchers for all but the current language (see http://drupal.org/node/242646), but of course this is just a dirty hack that works for me with my i18n and my language settings. I've no idea how general that is.
I just send the user to a predefined error page when no translation exists. You should create such a page for all languages and give it the same alias, see below. Then it works with my language settings of "Path prefix only". Since the error page is in the right language, the menu switches as expected.

Someonw with better knowledge should be able to make the href path configurable, for instance, or realize the dynamic solution (sketched in the comments below). But maybe this snippet helps some people for now.

  // shows language selection links and/or flags for all but the
  // current language. In contrast to the language switcher
  // block, it will send the user to a "translation does not exist"
  // page if a page with a language is missing a translation.

  // this is copy&paste from locale_block in locale.module
  $languages = language_list('enabled');
  $links = array();
  foreach ($languages[1] as $language) {
    $links[$language->language] = array(
        'href'       => $_GET['q'],
        'title'      => $language->native,
        'language'   => $language,
        'attributes' => array('class' => 'language-link'),
        );
  }

  // this adds the real paths, i.e. if we are on a german page,
  // the british flag will point to en/english_alias instead of 
  // en/node_with_german_content
  translation_translation_link_alter($links, $_GET['q']);

  // This one adds extended languages, i.e. those that are not enabled.
  // Disable if you want only flags for enabled languages.
  i18n_translation_link_alter($links, $_GET['q']);
  


  // now add or replace text links by flags, according to your i18n settings.
  //if (function_exists('languageicons_translation_link_alter'))
    languageicons_translation_link_alter($links, $_GET['q']);  

  // Or do your own stuff, e.g. set the flags and no lang names,
  // no matter what the i18n icon settings say.
  //if ($icon = theme('languageicons_icon', $language, NULL)) {
  //   $links[$language->language]['title'] = theme('languageicons_place', $link['title'], $icon);
  //   $links[$language->language]['html'] = TRUE;           
  //}
  
  // for pages that are not language neutral but have no translation for
  // a certain language, clicking the flag/link of that language will
  // change the current language, but the page and the menu will just stay.
  // When you chose another page afterwards it will still display in the old
  // language, but with a lang prefix of the new language (if you are using
  // language prefixes in the node path). And although the pages continue to
  // show e.g. in german, the current language is british so that you will see
  // a german flag while on a german page. Weired.
  // We correct that by sending the user to a "There is no translation for that
  // language" page. What you have to do: Create such a page for every language
  // that you have, and give *all* of those pages the same alias "no_translation".
  // With i18n in use and language setting "Path prefix only", this will send
  // you to de/no_translation, en/no_translatio etc. automatically. 
  // No other settings tested, but you can manipulate the link as you like,
  // e.g. give your translations aliases like "no_translation_en" etc. and
  // set the href to no_translation_$links[$langcode]['language']->language.
  // NOTE: the following code has only been tested with "Path prefix only" and
  // with i18n enabled.
  // Drawback: when you click the language flag while on the error page, you
  // are not redirected to the page you came from, but to the translation of
  // the error page. You could give your error page a little button to go back
  // to the former page using javascript or the referrer variable.
  // A way to solve this would be to dynamically generate a page when clicking the
  // language flag, configure this page as translation of the node you just viewed and
  // let the newly generated page display the error text. Shouldn't be that hard
  // for people with better drupal knowledge.
  $current = i18n_get_lang();
  $current_link=$links[$current];

  if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
    $node = node_load(arg(1));
  }
  // just work on pages that are not language neutral
  if (!empty($node->language)) {
    foreach ($links as $langcode => $link) {
      # if languages are different, but the hrefs are equal, than we have no translation
      if (($links[$langcode]['language']->language != $current) &&
          ($links[$langcode]['href'] == $current_link['href'])){
        // for people with more knowledge, you could make the target href
        // configurable by some menue settings for your own module...
        $links[$langcode]['href']='no_translation';
      }
    }
  }

  // remove the current language again. We cannot do that
  // earlier because i18n_translation_link_alter would add it
  // again, thinking it was an extendeg language because it
  // was not yet contained in $links. If you don't use 
  // i18n_translation_link_alter, you can also make a case distinction
  // in the foreach loop
  $current = i18n_get_lang();
  unset($links[$current]);

  // format as you like, e.g.
  echo theme('links', $links, array());

hass’s picture

Category: feature » support
Status: Active » Fixed

I haven't read all this many comments, but the topic is very old and sounds like you are searching for http://drupal.org/project/translation_overview. If you still think this is an issue, please reopen.

AaronCollier’s picture

Category: support » feature
Status: Fixed » Active

Translation Overview is a nice module, but I'm not sure it addresses this issue. This issue isn't about an overview of the situation, but what happens when an individual page without a translation is clicked on.

hass’s picture

Category: feature » support
Status: Active » Fixed

Come back if you know for sure that translation overview does not address this issue and please explains why not, please.

AaronCollier’s picture

Category: support » feature
Status: Fixed » Active

I installed Translation Overview and none of the behavior described here changed.

I go to a page in English that has no translation. Then I click the language flag. What happens is the menus, etc., change but the content remains in English. What this issue was asking for was for the content to change to something like "there is no translation for this page, please click here to start one" (in the target language). The block would send people to a specific page.

The problem was the presence of English on a page that said it was in German. This is a problem for a variety of reasons, including for accessibility, since the content is not labeled as English so assistive technology would still read it as German.

I do not think this is the highest priority request, but it is not a support request nor does translation overview do it. If you want to change it to "won't fix", that would seem possible.

castawaybcn’s picture

perhaps what you are looking for is this http://drupal.org/project/translation404

jose reyero’s picture

Status: Active » Closed (works as designed)

Right, that is the module, which is also linked from i18n front page, btw

Anonymous’s picture

This does not seem to work in Drupal 6.14

Fatal error: Call to undefined function i18n_translation_link_alter(