Hi,

Roller use ApplicationResource.properties as properties file for English 
language, no ApplicationResource_en.properties file there.

As the roller web application is deployed into a web container that has default 
locale in English, everything is okay. But when it is deployed into a container 
that default locale is not in English, and the ResourceBundle for the default 
locale’s language exists (such as zh_CN), problems coming:

When user want English language, a JSP page use struts MessageResource related 
tag to get i18n text will never get text in English, while text generated by 
JSTL fmt tag will get the right language. This is because of the difference of 
their ResourceBundle matching algorithm:

The JSTL searches resource bundle by following fallback algorithm roughly:

1.       ResourceBundle in English locale, (ApplicationResource_en…,) not exist

2.       Root bundle (ApplicationResource.properties), found, it’s in English

This is okay. But struts take different algorithm:

1.       ResourceBundle in English locale, (ApplicationResource_en…,) not exist

2.       ResourceBundle in container’s default locale, (for example, 
ApplicationResource_zh_CN, will take precedence, NOT English)

3.       Root bundle

This means struts makes web application has different behavior in different 
deployment environment, which JEE consider as a portable problem.

To solve the problem, there are 3 choices:

1.       At build time, generate a ApplicationResource_en.properties, which is 
just copied from ApplicationResource.properties

2.       Require the deployer to pay attention to this issue and always set the 
web container (JVM)’s default locale to English.

3.       Eliminate all struts MessageResoruce tags in JSPs, use JSTL instead. - 
Or may ask struts project to change its behavior to compatible with JEE 
standards ;-)

May be the first choice is the easiest way to solve the problem.

 

Re,

Miles.

Reply via email to