Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
zaheer mohammed saddapalli
Liferay to change Language based on Brower locale.
June 8, 2011 3:55 AM
Answer

zaheer mohammed saddapalli

Rank: Regular Member

Posts: 165

Join Date: January 15, 2008

Recent Posts

Hi All,

I am using Liferay EE 6.0.0.
Is there any configuration setting to make Liferay changes language based on Browser Locale.

Thanks in advance.

-Mohammed Zaheer
Thiago Leão Moreira
RE: Liferay to change Language based on Brower locale.
June 8, 2011 8:09 AM
Answer

Thiago Leão Moreira

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1433

Join Date: October 10, 2007

Recent Posts

Have you tried this configuration?

 1
 2##
 3## Languages and Time Zones
 4##
 5
 6    #
 7    # Set this to true if unauthenticated users get their preferred language
 8    # from the Accept-Language header. Set this to false if unauthenticated
 9    # users get their preferred language from their company.
10    #
11    locale.default.request=true
zaheer mohammed saddapalli
RE: Liferay to change Language based on Brower locale.
June 9, 2011 12:21 AM
Answer

zaheer mohammed saddapalli

Rank: Regular Member

Posts: 165

Join Date: January 15, 2008

Recent Posts

Thiago Leão Moreira:
Have you tried this configuration?

 1
 2##
 3## Languages and Time Zones
 4##
 5
 6    #
 7    # Set this to true if unauthenticated users get their preferred language
 8    # from the Accept-Language header. Set this to false if unauthenticated
 9    # users get their preferred language from their company.
10    #
11    locale.default.request=true


This is for unauthenticated users. I am checking for authenticated user. Its working fine if i set default language for the User.

I need to get Language based on Browser setting.


With Regards,
Mohammed Zaheer
David García González
RE: Liferay to change Language based on Brower locale.
June 23, 2011 3:27 AM
Answer

David García González

Rank: Regular Member

Posts: 127

Join Date: July 14, 2009

Recent Posts

It must be a filter or something similar that checks the configured language and displays the page on that language. You could start checking this filter in the source code.
Tejas Kanani
RE: Liferay to change Language based on Brower locale.
October 29, 2013 1:02 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 655

Join Date: January 6, 2009

Recent Posts

I was also looking for the same requirement. And did verify that we have solution for non-authenticated user. But for logged in user it's taking user's preferred language set in user's personal profile. If you still want to use the language set in Browser you need to code for it. If someone knows if we can do it without modifying the code, please share here !!!

By looking into the code for non-authenticated user, I've prepared a hook which does the same for logged in user. Basically it first checks for the browser selected language and verify whether it's there in Liferay's available languages set. If yes, it will update the cookie GUEST_LANGUAGE_ID value and also update/set "org.apache.struts.action.LOCALE" session attribute.

If someone looking for the same requirement and want to try the hook, packaged war can be download from browser-language-hook.
If you want to have a look into the code, it's added in Git Repo here.

Thanks,
Tejas