gtludwig
gtludwig

Reputation: 5611

thymeleaf + i18n - how to concatenate value from controller and i18n?

I have a table field that's supposed to display an internationalized value for a persisted boolean value.

In my i18n file, I have the folloing entries:

gen.true=<value for true>
gen.false=<value for false>

On the table, I have:

<td style="text-align: center" th:text="#{gen.${pojo.<value>}}">

If I leave it as:

<td style="text-align: center" th:text="${pojo.<value>}">

I only get true or false, without internationalization.

Instead of the current displayed value of

??gen.pojo.recurrent??

I'd like it to show <value for true> or <value for false>.

How to do so?

Upvotes: 2

Views: 535

Answers (1)

Yuki  Yoshida
Yuki Yoshida

Reputation: 1263

<td style="text-align: center" th:text="#{${'gen.' + pojo.recurrent}}">xxx</td>

or using preprocessing http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#preprocessing

<td style="text-align: center" th:text="#{gen.__${pojo.recurrent}__}">xxx</td>

Upvotes: 2

Related Questions