How can I force Grails to use only one language?

前端 未结 4 1219
梦如初夏
梦如初夏 2021-02-05 12:29

I want to make my Grails application support only one language, that I can define somewhere, completely ignoring the client\'s headers or the \"lang\" parameter. Is there any wa

4条回答
  •  清酒与你
    2021-02-05 13:26

    The default LocaleResolver of Grails is SessionLocaleResolver. If you want to always use de_DE you can change this to FixedLocaleResolver.

    beans {
      localeResolver(FixedLocaleResolver) {
          locale = new Locale("de", "DE")
      }
    }
    

    If you want to restrict to a set of locales, then you will need a filter, and use the SessionLocaleResolver#setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) method.

提交回复
热议问题