Click or drag to resize

Using Languages and Cultures

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Background

The Telogis.GeoBase.Internationalization namespace provides classes for accessing strings and audio announcements for language based operations. The classes rely upon a language configuration file, lang.xml, which specifies the necessary language information: language, cultures, strings, directions and announcements. Lang.xml resides in a language/culture-specific folder ("en-US", for example), along with the necessary audio files, in the langs folder, which is typically found at: \Program Files\Telogis\GeoBase\GeoBaseResources. Adding more languages or cultures is as simple as adding more language and culture-specific folders to the langs folder.

Note Note

The Internationalization namespace uses the CultureInfo class.

Internationalization is supported by GeoBase's MessagesBundle, an abstract class which provides access to internationalized messages (for example, strings and announcements) for a single culture.

GeoBase provides the developer with two concrete sub-classes: DirectoryMessagesBundle, and StringMessagesBundle. With the DirectoryMessagesBundle class, the messages for the culture are obtained from an XML file in a directory, allowing other resources (for example announcement sound files) to be obtained from the same directory. With the StringMessagesBundle class, messages and associated resources for the culture are obtained from an XML string.

To create a MessagesBundle object, use one of the following constructors:

C#
// DirectoryMessagesBundle
public DirectoryMessagesBundle(
    string rootPath,            // Root path containing directories for different cultures.
    string bundleFilename,         // Name of the XML file containing the configuration for a culture.
    CultureInfo culture,        // The bundle's culture.
    bool debugMode                // Whether debug mode will be used when generating strings. 
)

// StringMessagesBundle
public StringMessagesBundle(
    string XmlString            // XML configuration for the bundle, in either ASCII or UTF-8 format.
)

For example:

C#
// DirectoryMessagesBundle
string rootPath = Settings.GeoBasePath("langs");
// or use an absolute path, such as
// 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);

// StringMessagesBundle
MessagesBundle myMsgBundle = new StringMessagesBundle(xmlString);
Setting up the Navigator

The Navigator can be set up for specific languages and cultures with the overloaded constructor:

C#
Navigator(IGps gps, MessagesBundle messagesBundle)
Navigator(IGps gps, string langPath, CultureInfo culture)
Navigator(IGps gps, string langPath, CultureInfo culture, bool debugMode)

'langPath' provides the path to the directory containing the langs directory.

'culture' provides the language/culture specific information.

'debugMode', when set to true, tells the Navigator to:

  1. raise MessagesBundleExceptions when errors are found in the language configuration file

  2. print announcements to the console to aid in the development of new announcements

As an example:

C#
Navigator nav = new Navigator(myGps, myMsgBundle);
Setting up the NavigationManager

The NavigationManager can be set up for specific languages and cultures with the overloaded constructor:

C#
NavigationManager(MapCtrl map, string langPath, CultureInfo culture)
NavigationManager(MapCtrl map, string langPath, CultureInfo culture, bool debugMode)

'langPath' provides the path to the directory containing the langs directory.

'culture' provides the language/culture specific information.

'debugMode', when set to true, tells the NavigationManager to:

  1. raise MessagesBundleExceptions when errors are found in the language configuration file
  2. print announcements to the console to aid in the development of new announcements

As an example:

C#
NavigationManager navMgr = new NavigationManager(myMapCtrl, myLangPath, "en-US");
Routing with Directions

The Route class provides the overloaded GetDirections method where the Directions can be returned according to the given culture.

The following shows an example of how to obtain routing directions for a specific culture:

C#
// Set up the route
RouteStop rsA = new RouteStop(new LatLon(34.1018, -118.2973));
RouteStop rsB = new RouteStop(new LatLon(34.0720, -117.4962);                

// Create the route with the route stops
Route myRoute = new Route(rsA, rsB);

// Get the directions in the preferred language/culture
Directions myDirections = myRoute.GetDirections("en-US");
XMLWaveAnnouncer

The XmlWaveAnnouncer in the Telogis.GeoBase.Navigation namespace can be created by specifying both the culture and the path to the languages directory. If the path is not given then the XmlWaveAnnouncer uses a sounds directory set to the default langs directory in the GeoBase system's data path. If the culture is not specified, then the XmlWaveAnnouncer uses the a culture set to CurrentCulture.

The following example shows how to create an XMLWaveAnnouncer with a given sounds directory and culture.

C#
// Set up path to 'langs'
String langPath = Settings.GeoBasePath("langs");

// Set up culture
CultureInfo myCulture = new CultureInfo("en-US");

// Create announcer
WaveAnnouncer wa = new XmlWaveAnnouncer(langPath, myCulture);