Foros de discusión

Liferay to change Language based on Brower locale.

thumbnail
zaheer mohammed saddapalli, modificado hace 12 años.

Liferay to change Language based on Brower locale.

Regular Member Mensajes: 165 Fecha de incorporación: 15/01/08 Mensajes recientes
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
thumbnail
Thiago Leão Moreira, modificado hace 12 años.

RE: Liferay to change Language based on Brower locale.

Liferay Legend Mensajes: 1449 Fecha de incorporación: 10/10/07 Mensajes recientes
Have you tried this configuration?


##
## Languages and Time Zones
##

    #
    # Set this to true if unauthenticated users get their preferred language
    # from the Accept-Language header. Set this to false if unauthenticated
    # users get their preferred language from their company.
    #
    locale.default.request=true
thumbnail
zaheer mohammed saddapalli, modificado hace 12 años.

RE: Liferay to change Language based on Brower locale.

Regular Member Mensajes: 165 Fecha de incorporación: 15/01/08 Mensajes recientes
Thiago Leão Moreira:
Have you tried this configuration?


##
## Languages and Time Zones
##

    #
    # Set this to true if unauthenticated users get their preferred language
    # from the Accept-Language header. Set this to false if unauthenticated
    # users get their preferred language from their company.
    #
    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
thumbnail
David García González, modificado hace 12 años.

RE: Liferay to change Language based on Brower locale.

Regular Member Mensajes: 127 Fecha de incorporación: 14/07/09 Mensajes recientes
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.
thumbnail
Tejas Kanani, modificado hace 10 años.

RE: Liferay to change Language based on Brower locale.

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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