function to change language object I know this question may get the dafs-adrenalin of some of you viewers going. But I'm just recently getting my head in there with php and drupal and have been searching the api and googled a possible function only to find functions that did all sorts of other stuff. 

It's that I have this custom logic where I want to change the language object after I've set a $_COOKIE['lang']. The value of the cookie lang would be a language code like en or fr. And going $language-&gt;language -&gt; $_COOKIE['lang']; is pretty rediculous.

So the question maybe then is: I Know the value of $language-&gt;language, now I want to use the function that Drupal uses in core to construct the entire language object. This way the language object actually changes after the cookies is set and the locale module can to it's work to load the site in the new language?
The list of language objects is built up by the core function language_list(), which you can use to overwrite the global $language object if you need to:

// Get the list of languages
$languages = language_list();

// Set up the new language code
$new_lang_code = 'fr';

// Make sure the required language object is actually set
if (isset($languages[$new_lang_code])) {
  // Overwrite the global language object
  global $language;
  $language = $languages[$new_lang_code];
}