Is there a nicer way of getting my nodes language and text direction? My site is almost entirely in English, but with individual pages in different languages. There's one extra page per language other than English, as a single page "this is a summary of the sites information in your language" sort of deal.

I've used the Drupal "language" module to set up some languages and give some nodes a language other than English. I don't really want anything more complicated than this. Specifically I don't want:


To translate the entire site to any other language. 
To allow users to pick their language.
To translate anything other than node (single page) content. Menus,
site slogan, etc, will always be in English.


When viewing the pages for those nodes, I want to set some CSS classes and in some cases the text direction (rtl for Arabic / Urdu / Hebrew) based on the nodes language.

For some reason, the global $language variable is always set to English, regardless of the node language.

I can get the nodes language from $node-&gt;language and work out my CSS classes and text direction with the following code in my page.tpl.php:

&lt;?php
    $node_lang = 'en';
    if (isset($node) &amp;&amp; isset($node-&gt;language)) {
        $node_lang = $node-&gt;language;
        $rtl = ($node_lang == 'ar' || $node_lang == 'ur' || $node_lang == 'he');
    }
    $en = ($node_lang == 'en' || $node_lang == 'und');
?&gt;
&lt;div id="content"
    class="primaryContent &lt;?php if($rtl){print "rtl";}?&gt;"
    &lt;?php if ($rtl) { print "dir='rtl'"; } ?&gt;
    &lt;?php if (!$en) { print "lang='$node_lang' xml:lang='$node_lang'"; } ?&gt; &gt;
...content...
&lt;/div&gt;


Is there a simpler or "more recommended" way of doing the above? Doing my own detection of rtl / ltr feels fairly brittle.
If $node is the variable containing the node object, you can use code similar to the following one:

$languages = language_list();
if (isset($languages[$node-&gt;language])) {
  $rtl = $languages[$node-&gt;language]-&gt;direction == LANGUAGE_RTL;
  // $direction = $languages[$node-&gt;language]-&gt;direction ? 'rtl' : 'ltr';
}


If you need to use the string "rtl" or "ltr" basing on the direction associated with the language, then you can use $direction, instead of $rtl.