I'm looking for the function – if that exists – for asking Drupal about the current language direction (RTL/LTR).

I check the global language variable but it doesn't contain that information.

1 Answer 1


After looking more closely into $GLOBALS['language'] I found it actually has the language direction, so the answer is:

global $language;
if($language->direction == 1)
    echo 'RTL';
else /* $language->direction == 0 */
    echo 'LTR';

Better yet — thank you MPD, I can use the Drupal constants LANGUAGE_LTR and LANGUAGE_RTL instead of 0 and 1 respectively, just like this:

global $language;
if($language->direction == LANGUAGE_RTL)
    echo 'RTL';
else /* $language->direction == LANGUAGE_LTR */
    echo 'LTR';

For reference this is what $GLOBALS['language'] looks like:

stdClass Object
    [language] => ar
    [name] => Arabic
    [native] => 'Arabic' [it was in arabic letters but SE refused it]
    [direction] => 1
    [enabled] => 1
    [plurals] => 0
    [formula] => 
    [domain] => 
    [prefix] => ar
    [weight] => 0
    [javascript] => 
    [provider] => language-default
  • 1
    Instead of using 0 and 1, you should use LANGUAGE_LTR and LANGUAGE_RTL. See includes/bootstrap.inc
    – mpdonadio
    Commented May 13, 2013 at 20:55
  • 1
    Regarding, the native property. We had to ban the entire Arabic unicode block b/c of some very persistent spammers. If this becomes a problem with legit posts to DA, flag a post and we will see what we can do.
    – mpdonadio
    Commented May 13, 2013 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.