Search code examples
joomla

How can I get languages from the language manager in joomla?


How can I get the languages installed in the language manager in joomla, as I know the following:

  • getLocal() give for local machine language am not get the language installed in the application

  • getname() , getTag() give you the current language name / tag


Solution

  • This code returns the current language...

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

    By using the below query you can get all the languages installed in Joomla.

    $db =& JFactory::getDbo();
    $db->setQuery(
    'SELECT sef, title_native' .
    ' FROM #__languages' .
    ' ORDER BY sef ASC'
    );
    $options = $db->loadObjectList();
    

    If you installed any languages in joomla it will stored to #__extensions table with params. So you can get all the installed languages from the below query...

    $db =& JFactory::getDbo();
                $query = "SELECT name FROM #__extensions WHERE type='package'";
                $db->SetQuery($query);
                $options = $db->loadObjectList();
                echo "<pre>"; print_r($options);