You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Rafa (Jira)" <ji...@apache.org> on 2025/05/21 16:49:00 UTC

[jira] [Commented] (WW-5549) i18n interceptor param supportedLocale (when set) disables request_locale param functionality

    [ https://issues.apache.org/jira/browse/WW-5549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17953203#comment-17953203 ] 

Rafa commented on WW-5549:
--------------------------

It seems that not only {{?request_locale=}} functionality does not work then (when {{supportedLocale}} is used).
Any language change (e.g. by setting different locale to session under {{org.apache.struts2.interceptor.I18nInterceptor.DEFAULT_SESSION_ATTRIBUTE}} is not working as well.

> i18n interceptor param supportedLocale (when set) disables request_locale param functionality
> ---------------------------------------------------------------------------------------------
>
>                 Key: WW-5549
>                 URL: https://issues.apache.org/jira/browse/WW-5549
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 6.3.0
>            Reporter: Rafa
>            Priority: Minor
>
> It seems that when {{supportedLocale}} parameter is set on {{i18n}} interceptor - language change using {{request_locale}} param is not possible anymore if current browser {{Accept-Language}} matches the {{supportedLocale}} value.
> I set {{supportedLocale}} parameter on the {{i18n}} interceptor (e.g. to {{fr,en}} value). Now i enter the webapp (using a browser with fr language set as default) and the struts locale is set to {{fr}} (as expected - ok).
> Now i try switching the locale to {{en}} using the {{?request_locale=en}} built-in feature - but this does not work ({{{}fr{}}} is still set as language).
> If i do not set the {{supportedLocale}} param on the {{i18n}} interceptor - everything works fine (for exactly the same webapp, and the {{request_locale}} request param switch is working fine) but then i loose the feature of {_}struts preselecting fr language as default for browsers with fr language set as default{_}.
> When i look into the source code of [I18nInterceptor.java|https://github.com/apache/struts/blob/main/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java#L302] (line 302) it looks like {{AcceptLanguageLocaleHandler.find()}} is always returning one of the {{supportedLocale}} locales if browser has matching {{Accept-Language}} header - but it shall not e.g. when {{request_locale}} param is set (it shall take precedence here).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)