Hi everyone,

I have a block with php content and I would need to get the current language.
Something like $language (which doesn't work).

I installed the localizer module.

Thanks in advance.

Comments

krishnarp’s picture

function get_lang(){
global $language;
$lang = $language->language;
return $lang;
}
teebo’s picture

Thanks for the reply, but it does not seem to work:

global $language;
$lang = $language->language;

print("LANG: ". $lang);

Returns only... LANG:

Iumentum’s picture

use global $language; in drupal 6 instead of global $locale; wich is for earlyer versions of drupal!

teebo’s picture

Thanks, but, I'm currently using Drupal 5.
I'm waiting for modules to be Drupal 6 compatible.

Iumentum’s picture

no problem.
Most people is still waiting for views and CCK :S
Just though i would mention it for other readers there might come by this topic for solution.
But now you know the way when you start using D6 :)

rajab natshah’s picture

It's seem can work even if the user is not logged in.
I'm looking for direction as will..

It's seem that we can use something like this.

<?php 
 global $language;
  $lang = $language->direction;

  if ($lang ==1)
    print 'ltr';
  else
   print 'rtl';
?>

if $lang = 1 then it's left to right.. but if $lang = 0 then it's right to left

Regards

teebo’s picture

Thanks... you guided me on the right track.
Here's how I got it to work:

global $locale;
$lang = $locale;
omar alahmed’s picture

Thank you teebo, global $locale is the solution for drupal 5