Dear List,
We (that means my company) have an application with a file upload form. We
have set struts.multipart.maxSize to 5 MB. When a user tries to upload a
bigger file we rely on struts2 to generate an ActionError. Therefore the
framework uses the msg key
struts.messages.upload.error.SizeLimitExceededException from resource
bundle struts-messages. That bundle is available in several languages.
When I test that application code on my local dev box and request the msg
explicitly with Locale("en"), I get the text in german.
At first sight that seems like a framework bug.
But after some investigation I discovered that the JVM's resource bundle
resolving works not as I would expect.
In this case the following happens:
- struts2's algorithm is performed (search packages hierarchically)
- for global resources the JVM tries the file
"struts-messages_en.properties" which is not present
- then the JVM tries the language from system property "user.language"
which is "de" in my case
- a file for that locale is present and hence I get the german text
instead of the requested english one
We provide our application texts for english in 2 files (of course
scripted):
- bundle.properties
- bundle_en.properties
I propose as workaround that english framework texts are provided the same
way in 2 files.
At least I suggest to put a warning note on i18n wiki pages that
application developers should make sure to have "user.language" set to
"en".
Regards,
Christoph
This Email was scanned by Sophos Anti Virus