Skip to content

Commit fbe10f8

Browse files
committed
Auto configure localeChangeInterceptor
1 parent da5b179 commit fbe10f8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.grails.plugins.i18n;
22

3+
import org.grails.web.i18n.ParamsAwareLocaleChangeInterceptor;
34
import org.springframework.boot.autoconfigure.AutoConfiguration;
45
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
56
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
67
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
78
import org.springframework.context.annotation.Bean;
89
import org.springframework.web.servlet.DispatcherServlet;
910
import org.springframework.web.servlet.LocaleResolver;
11+
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
1012
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
1113

1214
@AutoConfiguration(before = { WebMvcAutoConfiguration.class })
@@ -18,4 +20,10 @@ public class I18nAutoConfiguration {
1820
public LocaleResolver localeResolver() {
1921
return new SessionLocaleResolver();
2022
}
23+
24+
public LocaleChangeInterceptor localeChangeInterceptor() {
25+
ParamsAwareLocaleChangeInterceptor localeChangeInterceptor = new ParamsAwareLocaleChangeInterceptor();
26+
localeChangeInterceptor.setParamName("lang");
27+
return localeChangeInterceptor;
28+
}
2129
}

grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nGrailsPlugin.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class I18nGrailsPlugin extends Plugin {
5959
}
6060
defaultEncoding = encoding
6161
}
62-
63-
localeChangeInterceptor(ParamsAwareLocaleChangeInterceptor) {
64-
paramName = "lang"
65-
}
6662
}}
6763

6864
@Override

0 commit comments

Comments
 (0)