Is there any API function to get the active/selected language in Drupal 6? There are different ways to negotiate the language in D6 (e.g. url prefix, $user->language, fallback language, ...), but how can I get the active language in a module? Checking $user->language is apparently not sufficient because one can override this with a url prefix (e.g. language switcher block). I couldnt find an API call like i18n_get_lang() (from i18n module) in Drupal 6.

Comments

profix898’s picture

I finally found it myself. There is no function but a global variable $language, which contains every information about the language of the current page request (see http://drupal.org/node/114774#language).

truecontact’s picture

hi

Thanks
I wanted to get active language for deciding what calendar system(like Hiriji or global calendar) to show

I used $language but it's null in my calendar file;

can any body help me?

j.somers’s picture

Did you make sure you selected the global one and not created a local copy?

function mymodule_foo() {
  global $language; // Contains all language information.
}