How to get Joomla’s Current Site Language

Getting Joomla Language Tags

Sometimes there is a need to get the current content/site language to use in other places. An example being when you want to set social share buttons to display in the same language as the site. Luckily Joomla makes this easy for us.

I have given 3 examples here. To use any of them you need to include the first line.

$lang = JFactory::getLanguage();
$languages = JLanguageHelper::getLanguages('lang_code');
$languageTag = $lang->getTag();
$languageCode = $languages[ $lang->getTag() ]->sef;
$languageName = $lang->getName();

The output of these variables for this page would be like this:

$languagetag = en-GB
$languageCode = en
$languageName = English (United Kingdom)