Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Lior Hadaya
How to change Liferay's culture in code
15 de Novembro de 2012 05:27
Resposta

Lior Hadaya

Ranking: Regular Member

Mensagens: 138

Data de entrada: 24 de Janeiro de 2012

Mensagens recentes

Hello,

I'm using Liferay EE 6.1.20 and I need to support a flow of changing the culture/language by the user.
How can I switch Liferay's culture in code?

I found the LocaleUtil class but I'm not sure if it would help, hard to understand what each method there actually does.

Please advise,

Thanks
Lior Hadaya
RE: How to change Liferay's culture in code
20 de Novembro de 2012 03:53
Resposta

Lior Hadaya

Ranking: Regular Member

Mensagens: 138

Data de entrada: 24 de Janeiro de 2012

Mensagens recentes

I figured out how to do it.
1#set ($language_url = $portletURLFactory.create($request, "82", $themeDisplay.getPlid(), "ACTION_PHASE"))
2$language_url.setWindowState("normal")
3$language_url.setPortletMode("view")
4$language_url.setParameter("struts_action", "/language/view")
5$language_url.setParameter("languageId", "fr_FR")


and then $language_url contains a URL that redirecting to it changes the portal's locale to French.
Hitoshi Ozawa
RE: How to change Liferay's culture in code
20 de Novembro de 2012 14:05
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7954

Data de entrada: 23 de Março de 2010

Mensagens recentes

You meant "country" instead of "culture". I think your question stunned a lot of people because of it. emoticon

Nice to see that you've figured it out yourself.
James Falkner
RE: How to change Liferay's culture in code
20 de Novembro de 2012 14:56
Resposta

James Falkner

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1222

Data de entrada: 17 de Setembro de 2010

Mensagens recentes

Hitoshi Ozawa:
You meant "country" instead of "culture". I think your question stunned a lot of people because of it. emoticon



emoticon
Jack Bakker
RE: How to change Liferay's culture in code
20 de Novembro de 2012 20:55
Resposta

Jack Bakker

Ranking: Liferay Master

Mensagens: 630

Data de entrada: 3 de Janeiro de 2010

Mensagens recentes

unique keyword culture is

(yoda grammer)
Lior Hadaya
RE: How to change Liferay's culture in code
20 de Novembro de 2012 22:37
Resposta

Lior Hadaya

Ranking: Regular Member

Mensagens: 138

Data de entrada: 24 de Janeiro de 2012

Mensagens recentes

Change country? that's even wierder emoticon
Language codes are also called [url=http://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx]cultrue codes
Hitoshi Ozawa
RE: How to change Liferay's culture in code
21 de Novembro de 2012 13:29
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7954

Data de entrada: 23 de Março de 2010

Mensagens recentes

Looking at the MS docs, it seems "culture code" is used to determine more than just the language used.

The CultureInfo class provides culture-specific information, such as the language, sublanguage, country/region, calendar, and conventions associated with a particular culture.


In Java, Locale is "language" and "country".
http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html

Another user was posting about changing calendar (e.g. Hijri). I've also asked liferay.com to change "conventions associated with a particular culture". It's currently not supported by liferay so I had to make my own additions.

That said, Liferay doesn't support "culture codes".