问题
I have a text for a key in my messages.properties
file with variables in it:
some.key=You'll need to pay {0} {1} in order to continue.
and I have it in both locales that my application supports: messages.properties
for English, and messages_tr.properties
for Turkish (the default Locale
).
So this works when I render the page with Turkish locale:
and I get:
Some Turkish words 10 USD some other Turkish words.
So, {0} {1}
gets replaced with the amount and currency. But it doesn't when I render the page in English:
You'll need to pay {0} {1} in order to continue.
What am I doing wrong? Thanks.
回答1:
Looks like the problem is in the single quote.
From here:
The single quote is used to represent a section within the message pattern that will not be formatted. A single quote itself must be escaped by using two single quotes ('')
So your message in messages.properties should be:
You''ll need to pay {0} {1} in order to continue.
来源:https://stackoverflow.com/questions/51675147/thymeleaf-doesnt-render-variables-within-messages-in-some-locales