Question

I know that we can get current language in Joomla by

$lang = JFactory::getLanguage();
echo 'Current language is: ' . $lang->getName();

now I want to know "How to get direction of current language in joomla 2.5?"

I try to use

dir="<?php echo $this->direction; ?>"

but It's not work and it returns empty string.

Was it helpful?

Solution

$this->direction can only be used on templates and there is no JLanguage property to get the actual value ltr or rtl. So you could do something along the lines if this instead:

$lang = JFactory::getLanguage();
$dir = $lang->get('rtl');

if($dir == 0) {
    //do soemthing
}
else {
    //do something else
}

OTHER TIPS

You may inspect your current language metadata and check the rtl property

$meta = JFactory::getLanguage()->getMetadata(JFactory::getLanguage()->getTag());
echo $meta['rtl'];

If $meta['rtl'] is 1 you are using a right to left language.

Pls. note that $this->direction is used on templates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top