How can I get languages from the langauge manager

2019-06-03 18:05发布

问题:

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

回答1:

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);


回答2:

From contentlanguage field type:

http://docs.joomla.org/Standard_form_field_types

JLanguage::getKnownLanguages()

You get a list like this:

Array
(
    [en-GB] => Array
        (
            [name] => English (United Kingdom)
            [tag] => en-GB
            [rtl] => 0
            [locale] => en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom
            [firstDay] => 0
            [weekEnd] => 0,6
        )

    [es-ES] => Array
        (
            [name] => Spanish (español)
            [tag] => es-ES
            [rtl] => 0
            [locale] => es_ES.utf8, es_ES.UTF-8, es_ES, spanish
            [weekEnd] => 0,6
        )

)


回答3:

This line returns an array of published languages

$languages = JLanguageHelper::getLanguages();


标签: joomla