This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/master by this push:
new 2fb9b9c WW-4929 Uses Accept-Language first, then fallbacks to Request
2fb9b9c is described below
commit 2fb9b9c77fb518bf47a631722dd565eb96212ee1
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Nov 28 10:46:48 2020 +0100
WW-4929 Uses Accept-Language first, then fallbacks to Request
---
.../struts2/interceptor/I18nInterceptor.java | 24 ++++++++++------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git
a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
index 5964693..e7d489e 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/I18nInterceptor.java
@@ -161,7 +161,7 @@ public class I18nInterceptor extends AbstractInterceptor {
} else if (this.storage == Storage.REQUEST) {
localeHandler = new RequestLocaleHandler(invocation);
} else {
- localeHandler = new AcceptLanguageHandler(invocation);
+ localeHandler = new AcceptLanguageLocaleHandler(invocation);
}
LOG.debug("Using LocaleFinder implementation {}",
localeHandler.getClass().getName());
@@ -276,32 +276,30 @@ public class I18nInterceptor extends AbstractInterceptor {
}
}
- protected class AcceptLanguageHandler extends RequestLocaleHandler {
+ protected class AcceptLanguageLocaleHandler extends RequestLocaleHandler {
- protected AcceptLanguageHandler(ActionInvocation invocation) {
+ protected AcceptLanguageLocaleHandler(ActionInvocation invocation) {
super(invocation);
}
@Override
@SuppressWarnings("rawtypes")
public Locale find() {
- Enumeration locales =
actionInvocation.getInvocationContext().getServletRequest().getLocales();
- while (locales.hasMoreElements()) {
- Locale locale = (Locale) locales.nextElement();
- if (supportedLocale.contains(locale)) {
- return locale;
+ if (supportedLocale.size() > 0) {
+ Enumeration locales =
actionInvocation.getInvocationContext().getServletRequest().getLocales();
+ while (locales.hasMoreElements()) {
+ Locale locale = (Locale) locales.nextElement();
+ if (supportedLocale.contains(locale)) {
+ return locale;
+ }
}
}
return super.find();
}
- @Override
- public boolean shouldStore() {
- return false;
- }
}
- protected class SessionLocaleHandler extends RequestLocaleHandler {
+ protected class SessionLocaleHandler extends AcceptLanguageLocaleHandler {
protected SessionLocaleHandler(ActionInvocation invocation) {
super(invocation);