Can someone shed some light on this problem:

I have nodes 1 (en), 2 (de), and 3 (lv) which are translations of each other. I additionally have a node 4 which is in English only (default language). Within the content of this node I want to reference the multilingual content of nodes 1,2 and 3 rsp. So if I switch to (en) I would like to link to node/1, if I switch to (de), I will see node 4 in (en), but want to link to node/2, if i switch to (lv), I want to link to to node/3. This is a problem with existing nodes.

I additionally have another node 5 in any language, that links to node 4. As node 4 is currently not translated this seems to be no problem. But if node 4 gets translations (with other node ids), I would like to link to the node in the current active interface language. This is a problem with currently not existing nodes.

I also think of a translator who has not much knowledge about internal drupal structures. I must be able to tell him/her, not to touch the href= values in the content. I can't tell him/her, to search for the companion node!

Comments

pepe roni’s picture

Title: Language independant reference to nodes » Reference to multilingual nodes

Further investigation did not lead to any results. Furthermore I discovered additional problems: How does the system recognize if I mean the translated companion node or if I mean this special node (whereas I think the first is the most case, but the latter must be kept in mind, too).
Do we need a special filter for this? Can Pathfilter, for example, be extended to this purpose? Pathfilter currently uses the interface (and not the translated node's!) language to resolve the path at save time. Can i18n provide such a filter?

Or am I missing something in i18n-Documentation

The solution is very urgent for me as I will have to set up an international, multilingual site and I have committed myself that this will be possible with Drupal (but I am currently very disappointed about the implementation of this feature. I thought, i18n was implemented into the drupal kernel) :(

pepe roni’s picture

Title: Reference to multilingual nodes » Language independant reference to nodes

Changed title.

pasqualle’s picture

Title: Reference to multilingual nodes » Language independant reference to nodes
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

it is wrong to mix languages..
so create a translation of you English only node, and your problem is gone..

there is no multilingual link support (as i know), you can't change links within node. when you change the language and you have English only node, nothing will change inside the node. your request is nonsense..

this has nothing to do with i18n 6.x, this is D6 core functionality..

pepe roni’s picture

Yes you are right! It is wrong to mix languages. But look at this scenario to explain my "nonsense":

You have three languages activated: en (default), de, lv.

Node 1 is available in en, node 2 is the translation of this node in de. There is another node in lv, that wants to reference the content in the translation of node 1 into lv (don't mix languages, you said!). As there is no translation available, node 1, as the default language is en, is referenced instead (en node content but lv interface lang!), hoping that automatically the lv translation will be referenced automatically as soon as it will be made available.

That's where language independent node references come into view. If this is still nonsense, let me know, please.

pasqualle’s picture

Version: 6.x-1.0-beta3 » 6.x-1.x-dev
Category: support » feature
Status: Postponed (maintainer needs more info) » Active

you should not create a link to node in different language (not even for default language)

but your request makes sense, anyway..
it could be a new filter like [link:node/1:de]

pasqualle’s picture

example:
this code replaces links which where set in 'en' language with links in actual language (if the node exists in actual language)


  $links['mypage1'] = array(
    'href'       => 'my/page1',
    'title'      => t('MyPage1'),
  );
  $links['mypage2'] = array(
    'href'       => 'my/page2',
    'title'      => t('MyPage2'),
  );

  drupal_alter('actual_language_link', $links, 'en');
  print theme('links', $links, array());
/**
 * Implementation of hook_alter_actual_language_link().
 *
 * Replaces links with pointers to translated versions of the content.
 */
function mymodule_actual_language_link_alter(&$links, $links_langcode) {
  global $language;

  foreach ($links as $key => $link) {
    $path = $links[$key]['href'];
    // Get all translation references for given path.
    if ($paths = translation_path_get_translations(drupal_get_normal_path($path, $links_langcode))) {
      if (isset($paths[$language->language])) {
        // Change the path to actual language.
        $links[$key]['href'] = $paths[$language->language];
      }
      else {
        // No translation in this language, or no permission to view.
        unset($links[$key]);
      }
    }
  }
}
pepe roni’s picture

Thanks for the code, but I'm a user, not a programmer.
What I need is a possibility to link language-neutral to a node, like /tnode/1 instead of /node/1. While /node/1 will display node 1, /tnode/1 will display the translated node corresponding to node 1.

Example:
node 1 is en, node 2 is de, node 3 is lv. So:

  • /en/node/1 will display node 1 with interface language (see: /en/...!) en.
  • /de/node/1 will display node 1 with interface language de
  • /lv/node/2 will display node 2 (the de one) with interface language lv

That's what drupal currently does!
Now, what I desire:

  • /de/tnode/1 will display node 2!
  • /lv/tnode/2 will display node 3 instead!

The node to display is determined by the interface language. The node ID within the url does only represent one translation of the node. The tnid of the node is taken to read the node in the desired language (the interface language). If there is no translation, the configured rules apply to display another translated node.

Would that be possible? No Filter!

pasqualle’s picture

Would that be possible?

Yes-drupal can do anything
No- nobody will do that for you, because your last request has a big flaw

1. tnode? no way

2

* /de/tnode/1 will display node 2!
* /lv/tnode/2 will display node 3 instead!

if you have 3 translations of the same node you can't use this syntax.. /lv/tnode/2 could mean node 1 also. you will not know which language you are referencing, that will be a mess..

3. simple rule: if you have a language independent link to a node and that node does not exist in actual language yet, then hide the link. when the node is translated the link will show up (without changing the link)..

pepe roni’s picture

Sorry, but I can't see any flaw:

.. /lv/tnode/2 could mean node 1 also

is not correct: it means the lv translation of node 2, if not available, use node 2 instead. And that's not ambiguous.

simple rule: if you have a language independent link to a node and that node does not exist in actual language yet, then hide the link. when the node is translated the link will show up (without changing the link)..

Could you please tell me how to reference a node that does currently not exist? Perhaps there is a notation with translations I do not now.

In my experience with language indicators in pathes (e.g. /lang/node/nid the node nid is displayed in it's language, but the interface language (that is all the texts around the node, in tabs, in blocks and so on) is displayed in lang.

jose reyero’s picture

Status: Active » Closed (won't fix)

Supporting mixed language for UI and content is a (wanted) feature.

And I see no better option when you are seeing a node for which there's no translation but you want to switch the interface language.

About these paths, instead of messing with the landing page, the best option is never producing/showing such a link. If Drupal gets a link with de/node/1 it will show the node 1 in whatever language with a German UI. This is 100% intended and desirable IMHO.

Plus, this are Drupal core links, the best option if you don't like the default block is to create a new one. Don't forget to contribute the php as a code snippet, http://drupal.org/node/313813 :-)