Spring的ResourceBundleMessageSource使用MessageFormat替换消息中的占位符({0})。
MessageFormat要求使用两个单引号('')转义单引号(') (参见:MessageFormat Javadoc)。但是,在默认情况下,不包含任何参数的消息不会被MessageFormat解析,因此不需要转义没有参数的消息中的单引号。
因此,在编写和维护资源包时,您的必须了解的两个规则:
''),则写入({0});')。在编写Spring资源边界时,是否有单一的规则来处理单引号?
发布于 2014-03-13 13:32:55
ResourceBundleMessageSource提供了一个名为alwaysUseMessageFormat的标志,如果应该将MessageFormat应用于所有消息,则可以使用该标志。
唯一的规则是..。
为所有资源配置一次:
<bean
id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="alwaysUseMessageFormat" value="true" />
...
</bean>在编写和维护资源包时,您的翻译必须注意到一个单一的规则():
'')另见Why Spring MessageSource arguments are not filled correctly in some locales。
https://stackoverflow.com/questions/22380243
复制相似问题