Community & Support

Arabic Translation of Node Title

We are using the i18n module. If the source document is english we need to translate into Arabic. There is no problem with the body of the text but we do not know how to translate the title of the node. If we translate the title when translating the node the automatic alias module creates an arabic alias which can be a very long text in arabic. We want to maintain the english alias but find a way to translate the title in Arabic. Is that possible. The node is a custom content type.

Comments

I had a similar request just

I had a similar request just recently. This is the code that I used to copy the url_alias from the source node to the translated node.

The idea is to translate your titles and then run this code to copy the source node url_aliases.

I hope this helps.

<?php
// copy_url_alias.php

include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$sql = "
        SELECT
          nid
        FROM
          {node}
        WHERE
          language = 'en'"
;
         
$query = db_query ( $sql);
while (
$request = db_fetch_object ( $query ) ) {
   
$nid = $request->nid;

   
$sql = "SELECT dst FROM {url_alias} WHERE src='node/".$nid."' AND language='en'";
   
$alias = db_result(db_query($sql));
   
    if (
$alias !== FALSE) {
   
       
$sql = "SELECT nid, language FROM {node} WHERE tnid=".$nid." AND language <> 'en'";
       
$tr_query = db_query ( $sql);
        while (
$tr_request = db_fetch_object ( $tr_query ) ) {
           
$tr_nid = $tr_request->nid;
           
$lang = $tr_request->language;

           
$sql = "SELECT dst FROM {url_alias} WHERE src='node/".$tr_nid."' AND language='".$lang."'";
           
$old_alias = db_result(db_query($sql));
           
            if (
$old_alias !== FALSE) {
                if (
$alias != $old_alias) {
                    echo
$lang . ' - ' . $alias . ' - '. $old_alias . "\n";
                   
$sql = "UPDATE {url_alias} SET dst='" . $alias . "' WHERE src='node/".$tr_nid."' AND language='".$lang."'";
                   
db_query($sql);
                }
            } else {
                echo
'No alias - ' . $lang . ' - ' . $alias . "\n";
               
$sql = "INSERT INTO {url_alias} (dst, src, language) VALUES('". $alias . "', 'node/".$tr_nid."', '".$lang."')";
               
db_query($sql);
            }
        }
    }   
}
?>
nobody click here