2

As the title says, how can I get the default language of my website?

For example, I have Farsi & English language in my website, and Farsi is my default language (but maybe sometimes I want to change it to English).

How can I find out which one is the default one?

2 Answers 2

5

The default language is stored as a parameter in the language component. So you can use this to get the default language: JComponentHelper::getParams('com_languages')->get('site');.

For the backend language it would be JComponentHelper::getParams('com_languages')->get('administrator');

0

In Joomla 4:

use Joomla\CMS\Component\ComponentHelper;

$defaultFrontendLanguage = ComponentHelper::getParams('com_languages')->get('site');

$defaultBackendLanguage = ComponentHelper::getParams('com_languages')->get('administrator');

$defaultFrontendLanguage could be a language label like "en-GB";

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.