How get programmatically Liferay default language or locale?
To change the language settings on an existing instance, open the Control Panel and navigate to Configuration → Instance Settings → Miscellaneous. Here you can change the default language, as well as define the current locales.
Check the com.liferay.portal.kernel.util.LocaleUtil class methods: LocaleUtil.getDefault() - returns default locale, LocaleUtil.toLanguageId(locale) - to get language ID from locale.
P.S. Note that LocaleUtil uses ThreadLocal to store defaul locale, so if you're doing this in new thread that you created, you should first call com.liferay.portal.security.auth.CompanyThreadLocal.setCompanyId(long companyId) method - this one will initialize LocaleThreadLocal and TimeZoneThreadLocal with default locale and timezlone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With