User login

Translated home page using i18n module and paths

Alternate title: Translation fun, an Agaric Design minisaga, starring the internationalization (i18n) module

We (OK, I) started off by editing the English version of a node out of existence when we thought we were creating a new translation. But we had revisions turned on! Self-knowledge, also the Agaric way.

Note that node revisions does not revert translation workflow states or even URL path settings. It does seem to have reverted menu settings, oddly enough.

On translation and internationalization:

Official docs, not so helpful:
http://drupal.org/node/133983

Also did not prove helpful, "Creating bilingual/multilingual Primary Links: instructions"
http://drupal.org/node/113325

The internet wouldn't answer me:

how to have a translated front page Drupal 5
i18n won't show translation drupal
Drupal i18n front page
drupal show different front page depending on language

The Drupal support IRC channel (#drupal-support on irc.freenode.net) at least commiserated, and I eventually found a hack that worked and reported it back there:

[7:40pm] agaric: the internationalization module
[7:40pm] agaric: (dramatic pause)
[7:42pm] agaric: isn't it supposed to somehow, some way show, for instance, the french translation of the front page node when one goes to, say, http://democraticmedia.ca ?
[7:43pm] Caydel: agaric: is that your site?
[7:43pm] agaric: yeah
[7:43pm] agaric: the people in Quebec are complaining that it's only in English
[7:43pm] Caydel: nice... there's a cause I can get behind
[7:44pm] agaric: hell yes
[7:44pm] Caydel: I never thought internationalization was supposed to translate your content
[7:44pm] Caydel: I thought it just did the site strings, forms, documentaition, explanations etc.
[7:44pm] agaric: no, you translate it, but the nodes are supposed to be linked somehow
[7:44pm] Caydel: ah, I see
[7:45pm] ot: agaric: take a look at the i18n module
[7:45pm] agaric: ot: that's what I'm using
[7:45pm] ot: lol
[7:45pm] ot: sorry
[7:46pm] • ot shakes my head
[7:46pm] agaric: so right now http://democraticmedia.ca/node/72 is the (loose) French translation, officially recognised as such by Drupal, of http://democraticmedia.ca/node/6
[7:46pm] agaric: node 6 is the home page
[7:46pm] agaric: So I really, really, really want http://democraticmedia.ca/fr to bring up node 72
[7:47pm] agaric: But really, really, really wanting hasn't been enough (so far)

[8:11pm] kthomas: agaric: why not just use a path alias /fr to the node?
[8:15pm] agaric: kthomas: good suggestion, but it doesn't work-- i18n's handling of /fr must override
[8:16pm] agaric: I still get the English front page. Blast.

[8:25pm] kthomas: pfft.
[8:26pm] kthomas: there should be a way to override i18n, but I haven't used it in ages
[8:28pm] agaric: I guess it just doesn't do what I expect it to do.
[8:28pm] agaric: http://democraticmedia.ca/en/node/76
[8:29pm] agaric: and http://democraticmedia.ca/en/node/77 are translations of one another
[8:29pm] agaric: I expect http://democraticmedia.ca/fr/node/76 to take me to the French version, whichever node is actually being linked to. But it's not going to do that.
[8:30pm] agaric: rgghh

[8:37pm] agaric: Sweet!
[8:38pm] agaric: OK, for kthomas, who cared
[8:38pm] agaric: Incoming URL's are now translated following these steps:
[8:38pm] agaric: 1. First, a translation is searched for path with language code: 'en/mypage'
[8:39pm] agaric: so I went to my site information page and changed the front page from node/6 to its alias, home (which is probably bad form, but hey)
[8:39pm] agaric: then I created a path alias fr/home to point to the translation, node/76
[8:39pm] agaric: and it works!
[8:40pm] agaric: http://democraticmedia.ca/
[8:40pm] agaric: oops, wait, no it defaults to French... please hold...
[8:41pm] agaric: no, it's doing exactly what it should

Alternate title: Translation fun, an Agaric Design minisaga, starring the internationalization (i18n) module

We (OK, I) started off by editing the English version of a node out of existence when we thought we were creating a new translation. But we had revisions turned on! Self-knowledge, also the Agaric way.

Note that node revisions does not revert translation workflow states or even URL path settings. It does seem to have reverted menu settings, oddly enough.

On translation and internationalization:

Official docs, not so helpful:
http://drupal.org/node/133983

Also did not prove helpful, "Creating bilingual/multilingual Primary Links: instructions"
http://drupal.org/node/113325

The internet wouldn't answer me:

how to have a translated front page Drupal 5
i18n won't show translation drupal
Drupal i18n front page
drupal show different front page depending on language

The Drupal support IRC channel (#drupal-support on irc.freenode.net) at least commiserated, and I eventually found a hack that worked and reported it back there:

[7:40pm] agaric: the internationalization module
[7:40pm] agaric: (dramatic pause)
[7:42pm] agaric: isn't it supposed to somehow, some way show, for instance, the french translation of the front page node when one goes to, say, http://democraticmedia.ca ?
[7:43pm] Caydel: agaric: is that your site?
[7:43pm] agaric: yeah
[7:43pm] agaric: the people in Quebec are complaining that it's only in English
[7:43pm] Caydel: nice... there's a cause I can get behind
[7:44pm] agaric: hell yes
[7:44pm] Caydel: I never thought internationalization was supposed to translate your content
[7:44pm] Caydel: I thought it just did the site strings, forms, documentaition, explanations etc.
[7:44pm] agaric: no, you translate it, but the nodes are supposed to be linked somehow
[7:44pm] Caydel: ah, I see
[7:45pm] ot: agaric: take a look at the i18n module
[7:45pm] agaric: ot: that's what I'm using
[7:45pm] ot: lol
[7:45pm] ot: sorry
[7:46pm] • ot shakes my head
[7:46pm] agaric: so right now http://democraticmedia.ca/node/72 is the (loose) French translation, officially recognised as such by Drupal, of http://democraticmedia.ca/node/6
[7:46pm] agaric: node 6 is the home page
[7:46pm] agaric: So I really, really, really want http://democraticmedia.ca/fr to bring up node 72
[7:47pm] agaric: But really, really, really wanting hasn't been enough (so far)

[8:11pm] kthomas: agaric: why not just use a path alias /fr to the node?
[8:15pm] agaric: kthomas: good suggestion, but it doesn't work-- i18n's handling of /fr must override
[8:16pm] agaric: I still get the English front page. Blast.

[8:25pm] kthomas: pfft.
[8:26pm] kthomas: there should be a way to override i18n, but I haven't used it in ages
[8:28pm] agaric: I guess it just doesn't do what I expect it to do.
[8:28pm] agaric: http://democraticmedia.ca/en/node/76
[8:29pm] agaric: and http://democraticmedia.ca/en/node/77 are translations of one another
[8:29pm] agaric: I expect http://democraticmedia.ca/fr/node/76 to take me to the French version, whichever node is actually being linked to. But it's not going to do that.
[8:30pm] agaric: rgghh

[8:37pm] agaric: Sweet!
[8:38pm] agaric: OK, for kthomas, who cared
[8:38pm] agaric: Incoming URL's are now translated following these steps:
[8:38pm] agaric: 1. First, a translation is searched for path with language code: 'en/mypage'
[8:39pm] agaric: so I went to my site information page and changed the front page from node/6 to its alias, home (which is probably bad form, but hey)
[8:39pm] agaric: then I created a path alias fr/home to point to the translation, node/76
[8:39pm] agaric: and it works!
[8:40pm] agaric: http://democraticmedia.ca/
[8:40pm] agaric: oops, wait, no it defaults to French... please hold...
[8:41pm] agaric: no, it's doing exactly what it should

Comments

Thanks, excellent article

Thanks for sharing.

I had the same issue, I "solved" it by hacking i18n.module:

function _i18n_goto($lang){
if(!function_exists('drupal_goto')){
require_once './includes/common.inc';
require_once './includes/path.inc';
}
//$home = variable_get('site_frontpage', '');
switch($lang){
case 'en':
$home = 'node/18';
break;
case 'nl':
$home = 'node/13';
break;
case 'de':
$home = 'node/1';
break;
case 'be':
$home = 'node/40';
break;
case 'es':
$home = 'node/33';
break;

}
drupal_goto($home);
}

Hardcoded rubbish, but it works without problems.

The method you discribe works nice too, I'm gonna give it a try.
Advantage of my "solution" is the fact that youre not hanging on URL aliasses.

Regards,

Kees

Drupal Development

David Mercer's Packt book addresses i18n

David Mercer's "Building powerful and robust websites with Drupal 6" (publisher: Packt Publishing) has a substantial section on i18n. See p. 275 (Chapter 9).

I should note

Agaric did full internationalization fairly successfully for the World Social Forum 2008 web site. There, a more complex site, all the content was generally accessed through a view or a panel, which provides a different set of issues. We were able to improve greatly on Drupal's handling of translated content – show translation if available, original if not – with a patch to Panels:

http://drupal.org/node/194441
Background: http://agaricdesign.com/note/remixing-drupal-agaric-way-multilingual-panels

But lots of internationalization, i18n itself, went into core in Drupal 6. It's a whole new (and much better) world.

Better solution

Make all the translated page have the same URL alias (e.g. home).

The under site configuration|site information change the default front page to be 'home'

http://drupal.org/node/249694#comment-1451240

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • 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> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.