Search code examples
javainternationalizationstrutsstruts-config

struts-config and message-resources : one Generic or one foreach langage


I supposed it is a quite easy question but I never receive any clear answer.

I'am currently handling the internationalization of a struts application. After a long research, i found out that I was missing something int the struts-config.xml : the message-resources.

<struts-config>
    ...
    <message-resources parameter="my.bundle"/>
</struts-config>

I wanted to know if I need to add a per langage ? Something like :

<struts-config>
    ...
    <message-resources parameter="my.bundle"/>
    <message-resources parameter="my.bundle_en"/>
    <message-resources parameter="my.bundle_it"/>
</struts-config>

or maybe struts will link the default bundle with all its versions ?


Solution

  • No you need only definition of your default resources for example

    <message-resources parameter="com.bundle" null="false" />
    

    and in your "res" directory create package "com" and put into it *.properties files for every language.

    bundle.properties
    bundle_en.properties
    bundle_de.properties
    

    Default properties is use for your default language. And for situation, that any key isn't find in any language, struts use key from default bundle.