Avoid huge URL aliases for non-English languages

When translating the title the automatic alias module creates an alias which can be a very long text in Asian and Middle Eastern languages (Arabic, Hebrew and Persian).

To overcome this it may be better to maintain the English alias. The following code does just this. What it does is to copy the alias for the English nodes to the translated nodes.

We will add this feature to our ICanLocalize module, allowing to choose what languages to copy the aliases to.

// copy_url_alias.php

include_once './includes/bootstrap.inc';

$sql = "
          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) {
$lang . ' - ' . $alias . ' - '. $old_alias . "\n";
$sql = "UPDATE {url_alias} SET dst='" . $alias . "' WHERE src='node/".$tr_nid."' AND language='".$lang."'";
            } else {
'No alias - ' . $lang . ' - ' . $alias . "\n";
$sql = "INSERT INTO {url_alias} (dst, src, language) VALUES('". $alias . "', 'node/".$tr_nid."', '".$lang."')";



Why exactly is keeping the English alias better? That would mean a huge hit when it comes to SEO.

This is not for all languages

This is not for all languages but only for those languages that end up with thier url encoded.
eg. Consider this English title:
Approved: kids dentals included in the medical coverage
which translates into Hebrew as:
אושר: טיפול שיניים לילדים על חשבון סל התרופות
Using this as a URL alias is fine untill you vew your site with Internet Explorer. The URL shown in Internet Explorer is:

on another note

Translated alias could mean a better google ranking.

and please read carefully:

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options