Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get programmatically Liferay default language or locale?

Tags:

liferay

How get programmatically Liferay default language or locale?

like image 482
Mark Avatar asked Aug 09 '12 10:08

Mark


People also ask

How do I change my default language in Liferay?

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.


1 Answers

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.

like image 94
mvmn Avatar answered Oct 14 '22 21:10

mvmn