Spring Boot Thymeleaf 国际化 i18n
Spring Boot Thymeleaf i18n About 549 words语法
#{}
示例
在th:text中使用#{}引入Resource Bundle中的i18n资源。
<a th:text="#{header_home}" th:href="@{/}">首页</a>
<a th:text="#{header_search}" th:href="@{/search.html}">搜索</a>YAML 配置
spring:
  messages:
    basename: file:${user.dir}/i18n/messages,classpath:i18n/messages
    cache-duration: 1h
    fallback-to-system-locale: true
  web:
    locale: eni18n 文件
messages.properties
header_home=HOME
header_search=SEARCHmessages_en.properties
header_home=HOME
header_search=SEARCHmessages_zh.properties
header_home=首页
header_search=搜索
                Views: 2,086 · Posted: 2023-08-17
            
            ————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
 
        Loading...