Search code examples
htmllocalizationthymeleaf

How to localize a thymeleaf input type=submit object?


Is there a way to localize an input type=submit object using Thymeleaf?

I have this: <input type="submit" value="Login"/>, but if I do this: <input type="submit" value="Login" th:text="#{msg.loginButton}"/> then the message is printed next to the "Login" button.

If I do this: <input type="submit" th:text="#{msg.loginButton}"/> the message is printed next to the login button, only this time "Submit Query" is printed on the button.

I would like to solve this without changing the class of the button itself, I want it to remain an input type=submit. Any suggestions?


Solution

  • The value attribute is no different than any other attribute you can set with ThymeLeaf.

    <input type="submit" th:value="#{msg.loginButton}" />