Why you shouldn’t use resource bundles with similar names
In this blog I would like to discuss a simple work around for a program limitation.
Using resource bundles enables portal applications to be displayed in different languages, you can create resource bundles that hold all language- or country-specific text strings or other resources.
In addition, you can create different resource bundles for each locale-country combination that you want to support, and then add these resource bundles to your WAR file. Your components can retrieve strings or other resources from these files.
Adding resource bundles to war file:
To add your resource bundles to a war file you need to:
- Place resource bundles in PORTAL-INF/private/lib (when packaged in JAR files) or in PORTAL-INF/private/classes (as individual files). The file extension is .properties.
- Define the name of the runtime resource bundle in the ResourceBundleName profile property in the portalapp.xml file.
For more information about using resource bundles please refer to http://help.sap.com
When loading two resource bundle files that one of the file names contains the name of the other file, the system will load the values from the last loaded file only.
For example: If one of the file’s name is “ResourceBundleFileName.properties”, and the other file’s name is “NewResourceBundleFileName.properties”, and the second one was loaded last,
Only values from NewResourceBundleFileName.properties will be used.
In order to avoid this situation, make sure that the names of your resource bundle files are different and avoid situation where one file name contains the name of the another file name.
As demonstrated below – none of the file’s names contains the name of another file.