Internationalization Namespace |
GeoBase provides the following classes in the Internationalization namespace:
These classes provide access to messages (that is, directions, strings and announcements) for a single culture.
The MessagesBundle class is abstract. GeoBase provides two concrete subclasses that can be used according to how the messages are configured. For example, use StringMessagesBundle when using an XML string, or DirectoryMessagesBundle when using an XML file in a directory on a disk.
Alternatively, by referencing instances of this abstract class rather than the concrete subclasses, the same code can access messages regardless of how they are configured.
The StringMessagesBundle class is a subclass of MesssagesBundle. The messages and associated resources for the culture are obtained from an XML string.
Note |
---|
The string must be encoded in either ASCII or UTF8 format. |
To set up a StringMessagesBundle object, simply pass the XML string to the constructor.
For example:
MessagesBundle myMsgBundle = new StringMessagesBundle(xmlString);
The DirectoryMessagesBundle class is a subclass of MessagesBundle. The messages for the culture are obtained from an XML file in a specified directory, allowing other resources (for example announcement sound files (.wav)) to be obtained from the same directory.
To set up a DirectoryMessagesBundle, pass the following arguments to the DirectoryMessagesBundle constructor:
string rootPath - the path to the directory containing the different directories of cultures
string bundleFileName - the name of the XML file containing the configuration for a culture
CultureInfo culture - the bundle's culture
bool debugMode - see note below
For example:
string rootPath = @"C:\telogis\geobase\geobaseresources\langs"; string bundleFileName = "lang.xml"; CultureInfo culture = new CultureInfo("en-US"); bool debugMode = false; MessagesBundle myMsgBundle = new DirectoryMessagesBundle( rootPath, bundleFileName, culture, debugMode);
Note |
---|
If debugMode is set to true, MessagesBundleExceptions will be thrown when errors are encountered in the language configuration file. If debugMode is set to false, when errors are encountered strings will be generated on a best effort basis and no MessagesBundleExceptions will be thrown. |