1

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.

3
  • does echo 'Current language is: ' . $lang->getName(); is working ? Commented May 4, 2014 at 13:06
  • I don't use that but It's in stackoverflow.com/questions/3352241/… Commented May 4, 2014 at 13:08
  • please check it and let us know ? Commented May 4, 2014 at 13:08

2 Answers 2

1

$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
}
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.