【发布时间】:2015-12-06 14:24:54
【问题描述】:
我正在尝试将我当前的 spring-boot / thymeleaf 项目的观点国际化。到目前为止,我这样做了:
-
在 html 文件中,我将对文本的引用更改为:
h2 th:text="#{about.title}"
-
我将此行添加到我的
application.properties文件中:spring.messages.basename=i18n/messages
-
将文件
李>*.properties(与默认语言环境的html文件同名,葡萄牙语言环境的后缀_pt_BR放在我项目的文件夹/src/main/resources/templates/i18n/messages中。
但是当我运行项目并在浏览器中打开它时,我看到的不是正确的消息,而是>??about.title??。
我在这里做错了什么?
【问题讨论】:
-
你能不能试着把你的属性文件放在这里/src/main/resources/i18n/messages。
-
@GUISSOUMAIssam 我解决了这个问题,将所有消息放在
/src/main/resources目录中的单个message.properties中(并从application.properties中删除行spring.messages.basename=i18n/messages。但现在我得到了一个像这样的本地化消息问题:logo.welcome=Welcome, <a th:href="@{/login}">log in</a> or <a th:href="@{/account}">register</a>(带有@{...}变量)。
标签: spring internationalization spring-boot thymeleaf