【问题标题】:Spring Boot Thymeleaf InternationalizationSpring Boot Thymeleaf 国际化
【发布时间】:2018-01-27 04:05:38
【问题描述】:

我无法在 Spring Boot Thymeleaf 中实现自定义属性(例如 HTML5 数据属性、数据工具提示)的国际化。这是示例代码。

<a class="active" th:text="#{label.management}"></a>
...
<input type="text" th:field="*{username}" th:placeholder="#{label.username}" />
...
<div class="fixed-action-btn tooltipped" data-position="left" data-delay="50" th:data-tooltip="#{label.quicklinks}">
    <a class="btn-floating btn-large orange">
        <i class="large icons ion-edit"></i>
    </a>
    ....
</div>

他们 th:text 和 th:placeholder 没问题。但是 th:data-tooltip 会打印一个空字符串。

我想了解如何在自定义 HTML 元素上实现 Spring Boot thymeleaf 翻译。谢谢。

【问题讨论】:

    标签: spring spring-mvc thymeleaf spring-bean


    【解决方案1】:

    这是 Thymeleaf 2.x 中的一个问题,请参阅 https://github.com/thymeleaf/thymeleaf/issues/489

    升级到 3.x 或使用 th:attr 作为解决方法。 https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#setting-value-to-specific-attributes

    例如

    th:attr="data-tooltip=#{label.quicklinks}"/>
    

    【讨论】:

      猜你喜欢
      • 2018-01-26
      • 2016-02-23
      • 2015-07-07
      • 1970-01-01
      • 2018-12-05
      • 2021-04-17
      • 1970-01-01
      • 2018-05-12
      • 2018-11-15
      相关资源
      最近更新 更多