Fórum

Liferay to change Language based on Brower locale.

thumbnail
zaheer mohammed saddapalli, modificado 12 Anos atrás.

Liferay to change Language based on Brower locale.

Regular Member Postagens: 165 Data de Entrada: 15/01/08 Postagens Recentes
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 12 Anos atrás.

RE: Liferay to change Language based on Brower locale.

Liferay Legend Postagens: 1449 Data de Entrada: 10/10/07 Postagens Recentes
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 12 Anos atrás.

RE: Liferay to change Language based on Brower locale.

Regular Member Postagens: 165 Data de Entrada: 15/01/08 Postagens Recentes
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 12 Anos atrás.

RE: Liferay to change Language based on Brower locale.

Regular Member Postagens: 127 Data de Entrada: 14/07/09 Postagens Recentes
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 10 Anos atrás.

RE: Liferay to change Language based on Brower locale.

Liferay Master Postagens: 654 Data de Entrada: 06/01/09 Postagens Recentes
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