Retrieving a Resource Bundle
In the Internationalization Module, when an application needs localized data, it constructs an RWUResourceBundle, then queries the instance for the needed resources. The constructors for RWUResourceBundle accept the name of a directory containing .res or .dat files, and the name of a locale. For example:
 
RWUResourceBundle enUSData =
RWUResourceBundle("C:\\data", "en_US");
If no locale is given, or an empty or null locale is passed, the default locale is used. (See The Default Locale.)
The constructor may succeed, succeed through fallback, or fail, depending on whether an exact match to the requested locale is found, a fallback match is found, or no bundle at all is found; for instance, if the resource path does not exist.
The fallback mechanism works as follows:
1. The library first looks for the exact named RWUResourceBundle.
2. Failing that, the library looks for a parent locale along the named locale’s branch in the resource hierarchy (see The Resource Hierarchy).
3. If no parent locale is found, the library looks for the locale named by RWULocale::getDefault().
4. Failing that, the library looks for a parent locale along the default locale’s branch in the resource hierarchy.
5. Failing that, the library attempts to open the RWUResourceBundle named root.
6. Finally, if it can find no information for any of the above mentioned locales, the library throws an RWUException.
For example, suppose the RWUResourceBundles shown in Figure 2 are defined, and that the current default RWULocale is es_ES.
Figure 2 – Sample resource bundle hierarchy
In this case, if you attempt to open the RWUResourceBundle named ja_JP, the library tries these bundle names in order:
1. ja_JP -- the exact match
2. ja -- the parent
3. es_ES -- the default locale
4. es -- the default parent: Success!
5. if es been missing, root would have been tried next
Constructors throw an RWUException if no bundle is found, but otherwise succeed and cache an RWUStatusCode to indicate the level of success. The getStatus() method returns an RWUStatusCode indicating whether fallback occurred during the creation or retrieval of the resource bundle:
*RWUNoError
There was a bundle with an exact match for the requested RWULocale.
*RWUUsingFallbackWarning
There was a bundle with a fallback match for the requested RWULocale, but there was no exact match.
*RWUUsingDefaultWarning
Neither a bundle for the requested RWULocale nor any of its parents was found. The newly-constructed RWUResourceBundle contains data associated with the current RWULocale::getDefault() locale, with one of its parents, or with the root RWUResourceBundle.
If fallback occurred, you can use method getLocale() to return the actual locale where the resource bundle was found, as opposed to the locale originally requested. Method getLocaleName() returns the name of the locale; it is a convenience synonym for getLocale().getName().
Note that it is normal to expect fallbacks. Some programs don’t need to distinguish resources for all locales.