Hi,
After my post Spring: Internationalization with message source, I write a mini-post concerning a problem known in MessageSource of Spring for the message containing apostrophe or quote.
Indeed, there is a known issue (JIRA SPR-9169) in the Spring MessageSource component, a single apostrophe (or quote) is ignored and all text between quotes containing two parameters {1}, {2} is interpreted as plain text.
Example:
A simple Spring message source configuration in web application:
applicationContext.xml
<!-- ################### SPRING APPLICATION MESSAGES PROPERTIES ################### --> <!-- Files concerned: --> <!-- /WEB-INF/ApplicationMessageSource.properties --> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="defaultEncoding" value="UTF-8"/> <property name="basenames"> <list> <value>classpath:ApplicationMessageSource</value> </list> </property> </bean>
ApplicationMessageSource.properties
####### General messages ########### alert.message=You don't have the permissions to {0} in {1}. Don't panic, your role is {2}!
-> In this case, the {0} and {1} parameters will be ignored, only, the parameter {2} will be replaced.
Solution: double the apostrophes in your messages
####### General messages ########### alert.message=You don''t have the permissions to {0} in {1}. Don''t panic, your role is {2}!
Dear visitors, have you more efficient or intelligent solution?
That’s all!!!
Huseyin OZVEREN
I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back in the future. Cheers
Thank you Basilia for your message. Kind regards.
Thanks, it works! 🙂