我有一条短信要我的钥匙 messages.properties 包含变量的文件:
messages.properties
some.key=You'll need to pay {0} {1} in order to continue.
我的应用程序支持两种语言环境: 消息.属性 对于英语,以及 messages_tr.properties 土耳其语(默认 Locale ).
消息.属性
messages_tr.properties
Locale
因此,当我使用土耳其语区域设置呈现页面时,这会起作用:
我得到:
Some Turkish words 10 USD some other Turkish words.
所以, {0} {1} 替换为金额和货币。但当我用英语呈现这一页时:
{0} {1}
You'll need to pay {0} {1} in order to continue.
我做错什么了?谢谢。
看来问题出在单引号里。
从 here :
单引号用于表示消息模式中不格式化的部分。单引号本身必须使用两个单引号('')转义
因此,messages.properties中的消息应该是:
You''ll need to pay {0} {1} in order to continue.