I'm not the first to ask, but I believe there must be a simple script possible so that a user can switch to another localisation (language) with a simple click. In my case, the default is French and I want English users to simply click on a link called, for example, "English navigation" (instead of asking them to create an account, etc.).
I imagine the "simplest" might be a script that identifies the default language selected in the user's browser (IE, Netscape, etc.) and tells Drupal to use that localisation for the session.
BUT it wouldn't always work, so I tried the following code proposed by Steph* a good while ago. Unfortunately, I couldn't figure out where to write "en" or "English" in the code to make it work. Yet I don't even know if this small php file would override the default language on my site.:?
Can someone tell me if this php trick would work and where to stick the "en" or "English"?
Thanks,
Mic
function locale_init() {
global $defaultLanguage,$lang,$languages;
// first set the defaultLanguage, if lang was passed in php
// initialize localization system
session_register("defaultLanguage");
if ($lang)
$defaultLanguage = $lang;
return ($languages ? ((is_object($user) && $user->id &&
$user->language) ? $user->language : $defaultLanguage ? $defaultLanguage
: key($languages)) : 0);
}
[This is followed by an html script to return to the main page of the site]
* Found at:
http://lists.drupal.org/archives/drupal-support/2002-12/msg00044.html