What do you think about this code. This code makes possible to load different language versions of node without using path aliases.
For example:
we have node language versions:
node/10 - english (en)
node/11 - french (fr)
node/12 - german (de)
Now it will work so:
en/node/10 will load english version - node 10
fr/node/10 will load english version - node 11
de/node/10 will load english version - node 12
The code itself: [node.module]
---...---
// Retrieve the node.
$node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.*, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE '. implode(' AND ', $cond))));
$node = drupal_unpack($node);
// the new part
if ( $node->language != $GLOBALS['locale'] ) // comparing active language and node language
{
$translations = db_query("SELECT trid FROM {i18n_node} WHERE nid = $conditions[nid]"); // finding translations
$trid_ids = db_fetch_array($translations);
$trid_ids['trid'];
if ( $trid_ids['trid'] )
{
$node_translation = db_query("SELECT n.nid, n.language FROM {i18n_node} iln, {node} n WHERE n.nid = iln.nid AND iln.trid = $trid_ids[trid]");
while ( $node_lang = db_fetch_array($node_translation) )
{
if ( $node_lang['language'] == $GLOBALS['locale'] ) // If we found it - then reload the node info
{
$node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.*, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE n.nid = ' . $node_lang['nid'])));