Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to get locales?
Mirto Silvio Busico, modified 7 Years ago.
Regular Member
Posts: 240
Join Date: 1/18/12
Recent Posts
Hi all,
I'm trying to get the list of available locales in a portlet.
using a code similar to https://www.programcreek.com/java-api-examples/index.php?api=com.liferay.portal.kernel.util.LocaleUtil example 4, I put in my portlet:
Locale[] locales = LanguageUtil.getAvailableLocales();
But I receive the compilation error:
Type mismatch: cannot convert from Set<Locale> to Locale[]
What I'm doing wrong?
(I'm on Liferay 7.1 CE GA 1)
Mirto Silvio Busico:Locale[] locales = LanguageUtil.getAvailableLocales();But I receive the compilation error:
Type mismatch: cannot convert from Set<Locale> to Locale[]What I'm doing wrong?
(I'm on Liferay 7.1 CE GA 1)
In Liferay 6.2, LanguageUtil.getAvailableLocales returns an array, while in Liferay 7.1, LanguageUtil.getAvailableLocales returns a Set. You'll need to adapt the code sample accordingly.
Set<Locale> locales = LanguageUtil.getAvailableLocales();
Mirto Silvio Busico, modified 7 Years ago.
Regular Member
Posts: 240
Join Date: 1/18/12
Recent Posts
Thanks,
it worked.