Hello everybody,

I just want to know if there is a function in drupal to know what language is configurated for the user which is currently visiting the website, so that i can print "welcome, you are reading an english text" or "welcome, you are reading a french text" ?

Thanks a lot

Comments

pobster’s picture

A function in Drupal or a browser/ os language setting?

Drupal handles locales like this;

  if (module_exists('locale')) {
    global $locale;
    print $locale;
  }

Pobster

nachenko’s picture

The $language object is your friend. Have a look at it:

stdClass Object
(
    [language] => es
    [name] => Spanish
    [native] => Español
    [direction] => 0
    [enabled] => 1
    [plurals] => 2
    [formula] => (($n==1)?(0):1)
    [domain] => 
    [prefix] => es
    [weight] => 0
    [javascript] => fd874c68846b6b0e05525be83e2bbd98
)