【发布时间】:2016-07-17 16:19:21
【问题描述】:
加载和包含模板时,Freemarker(默认)uses the locale to build the file names it looks for。例如,使用 en_US 语言环境加载 tos.ftl(模板)会查找:
- tos_en_US.ftl
- tos_en.ftl
- tos.ftl
当页面在不同语言之间完全不同时,这对于翻译整个页面很有用。例如,“服务条款”页面可能大部分是静态的,因此不同的语言会有完全不同的内容。在这种情况下,将整个内容外部化为从消息包加载的消息是一件麻烦事。
我现在正在学习 Thymeleaf,但找不到任何关于类似功能的信息。我知道 Thymeleaf 使用localized message bundles 填充th:text 元素,但它可以加载模板文件的本地化版本吗?
注意:我使用的是 Spring Boot
【问题讨论】:
-
我为此打开了一个功能请求:github.com/thymeleaf/thymeleaf/issues/497
标签: spring spring-mvc spring-boot freemarker thymeleaf