【发布时间】:2016-05-09 00:54:54
【问题描述】:
我在 Spring Boot 中使用 thymeleaf,
<span th:text="#{home.welcome}">Welcome Default Message</span>
当在messages.properties中找不到key时,我有
??home.welcome_en_US??
我不想翻译messages.properties 中的每条消息。当找不到翻译关键消息时,我希望在 html 页面中写入“欢迎默认消息”。
我该怎么做?
【问题讨论】:
-
然后将其添加到您的
messages.properties中,该文件中的值基本上是默认值。message_yourLanguage.properties包含已翻译的内容。 -
其实我并不想创建默认messages.properties,我想在thymeleaf html模板中使用默认message。
-
你不能因为它们总是被替换,这就是百里香叶的工作原理。也许在自定义方言中有一个解决方案,您可以在其中指定表达式中的默认值。
标签: spring internationalization spring-boot thymeleaf