Set the fallback locale
the <g:message code="x.y" />
tag tries to resolve the code in the message bundle with the current locale and if it can't find it, it will fall back to english as default fall back locale.
That's fine if your primary language is english. But where can I change this behaviour so that it does a fallback to a diffrent locale开发者_StackOverflow?
It fallbacks to messages.properties
, it's default messages, not english. Just fill it using your primary language, that's all
You can configure the localeResolver bean in spring.
In the resources.groovy put:
beans = {
def grailsApplication = ApplicationHolder.application
localeResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) {
defaultLocale = new Locale(grailsApplication.config.language, grailsApplication.config.languageCulture)
java.util.Locale.setDefault(defaultLocale)
}
}
And in the config.groovy configure the language properties "language" and "languageCulture".
language = "es"
languageCulture = "MX"
精彩评论