开发者

Set the fallback locale

开发者 https://www.devze.com 2023-03-26 03:35 出处:网络
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.

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消