-1

I'm working with Spring Boot + Thymeleaf. I want to internationalize something like this:

<p>Already registered? <span class="link">Log In</span></p>

If I add th:text="#{prompt}" to the <p> tag, the inner span will be replaced by the property value.

Is there any way to internationalize the whole text of <p> element with just one property in my resource bundle? (maybe with placeholders or I don't know)

Mahozad
  • 18,032
  • 13
  • 118
  • 133

1 Answers1

1

You could add placeholders for the html tags inside the property value

Property:

prompt = Already registered? {0}Log In{1};

Html:

<p th:utext="#{prompt('<span class=link>', '</span>')}"></p>

Note: I am using th:utext instead of th:text because it doesn't escape html.

But it would be clearer if you would just have two different properties. E.g.:

<p>
    <th:block th:text='#{prompt1}'></th:block>
    <span class='link' th:text='#{prompt2}'></span>
</p>
Alexandru Severin
  • 6,021
  • 11
  • 48
  • 71