春季启动/百里香叶项目中的 i18n 它不会检索本地化消息



我正在尝试将我当前的spring-boot/thymleaf项目的视图国际化。到目前为止,我是这样做的:

    在html文件中
  • ,我将对文本的引用更改为:

    h2 th:文本= " # {about.title} "

  • 我将这行添加到我的application.properties文件:

    spring.messages.basename = i18n/消息

  • *.properties文件(与默认语言环境的html文件同名,葡萄牙语语言环境的后缀为_pt_BR)放在我的项目文件夹/src/main/resources/templates/i18n/messages中。

但是当我运行项目并在浏览器中打开它时,而不是显示正确的消息,我看到的是> ??about.title??

我在这里做错了什么?

你可以把你的属性文件放在/src/main/resources/i18n/messages而不是/src/main/resources/templates/i18n/messages

最新更新