-
-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '7.0.x' into feature/7.0.0/13655-dot-notation
- Loading branch information
Showing
11 changed files
with
332 additions
and
38 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
grails-plugin-i18n/src/main/groovy/org/grails/plugins/i18n/I18nAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.grails.plugins.i18n; | ||
|
||
import grails.config.Settings; | ||
import grails.core.GrailsApplication; | ||
import grails.plugins.GrailsPluginManager; | ||
import grails.util.Environment; | ||
import org.grails.spring.context.support.PluginAwareResourceBundleMessageSource; | ||
import org.grails.web.i18n.ParamsAwareLocaleChangeInterceptor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | ||
import org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration; | ||
import org.springframework.context.MessageSource; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.support.AbstractApplicationContext; | ||
import org.springframework.web.servlet.DispatcherServlet; | ||
import org.springframework.web.servlet.LocaleResolver; | ||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; | ||
import org.springframework.web.servlet.i18n.SessionLocaleResolver; | ||
|
||
@AutoConfiguration(before = { MessageSourceAutoConfiguration.class, WebMvcAutoConfiguration.class }) | ||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) | ||
public class I18nAutoConfiguration { | ||
|
||
@Value("${" + Settings.GSP_VIEW_ENCODING + ":UTF-8}") | ||
private String encoding; | ||
|
||
@Value("${" + Settings.GSP_ENABLE_RELOAD + ":false}") | ||
private boolean gspEnableReload; | ||
|
||
@Value("${" + Settings.I18N_CACHE_SECONDS + ":5}") | ||
private int cacheSeconds; | ||
|
||
@Value("${" + Settings.I18N_FILE_CACHE_SECONDS + ":5}") | ||
private int fileCacheSeconds; | ||
|
||
@Bean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME) | ||
public LocaleResolver localeResolver() { | ||
return new SessionLocaleResolver(); | ||
} | ||
|
||
@Bean | ||
public LocaleChangeInterceptor localeChangeInterceptor() { | ||
ParamsAwareLocaleChangeInterceptor localeChangeInterceptor = new ParamsAwareLocaleChangeInterceptor(); | ||
localeChangeInterceptor.setParamName("lang"); | ||
return localeChangeInterceptor; | ||
} | ||
|
||
@Bean(AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME) | ||
public MessageSource messageSource(GrailsApplication grailsApplication, GrailsPluginManager pluginManager) { | ||
PluginAwareResourceBundleMessageSource messageSource = new PluginAwareResourceBundleMessageSource(grailsApplication, pluginManager); | ||
messageSource.setDefaultEncoding(encoding); | ||
messageSource.setFallbackToSystemLocale(false); | ||
if (Environment.getCurrent().isReloadEnabled() || gspEnableReload) { | ||
messageSource.setCacheSeconds(cacheSeconds); | ||
messageSource.setFileCacheSeconds(fileCacheSeconds); | ||
} | ||
return messageSource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.grails.plugins.i18n.I18nAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters