URL aliases without language prefix

nexus246 - June 4, 2007 - 11:42
Project:Internationalization
Version:5.x-2.1
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:won't fix
Description

I needed to get i18n block work with translated nodes and their different aliases without language prefix.
for example

node/16 -> o-projekcie ( first language )
node/19 -> about-project ( node 16 translated to second language )

I made some changes to i18n_get_links:

<?php
function i18n_get_links($path = '', $query = NULL, $names = NULL) {
  if(
$path == i18n_frontpage()) {
   
$path = '';
  }
 
$names = $names ? $names : i18n_languages('native');
  foreach (
array_keys(i18n_supported_languages()) as $lang){
     
$nid = arg(1);
       
//if this is node and we have node id
     
if( arg(0)=='node' && !empty($nid) ) {
               
//if lang in loop is different that current website lang get translation id
         
if(i18n_get_lang()!=$lang) {
             
$node = node_load(arg(1));
           
$path = 'node/' . $node->translation[$lang]->nid;
               
//else set path to current node value if we still need current lang flag
         
} else {
             
$path = 'node/' . $nid;
          }
      }
   
$links[$lang]= theme('i18n_link', $names[$lang], i18n_path($path, $lang), $lang, $query);
  }
  return
$links
}
?>

Sorry that im not using patch, im not very familiar with CVS.
Please let me know what do you think about these changes.

#1

Jose Reyero - November 6, 2009 - 15:20
Status:needs review» won't fix

No new features for 5.x.

Try 6.x

 
 

Drupal is a registered trademark of Dries Buytaert.