Click or drag to resize

The Language Configuration File

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
The language configuration file

The language configuration file, lang.xml, provides the Internationalization classes with specific language information: language, cultures, directions, strings, and announcements. The format of the file is:

XML
<Lang>
  <Desc>
  <Cultures>
  <Directions>
  <Strings>
  <Announcements>
</Lang>

The Directions, Strings and Announcements elements comprise two further elements each: Phrases, and Groups.

Desc

Each lang.xml file has a Desc node, which describes the language. For example:

XML
<Desc>English (US)</Desc>

Cultures

The lang.xml file also has a set of Culture nodes which describe the cultures that the language should be used for. Most cultures are written: language-country but some may be written language-script-country or even language-country-script. See http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx for more information.

When matching a culture, GeoBase will look for an entry that matches the full culture string. If there is no match, GeoBase will remove the final dash and everything that follows it, and then retry. GeoBase will repeat until it tries to match against an empty string, which means the default culture. So when the specified culture is en-GB, GeoBase will look for a lang.xml file containing "en-GB" then "en" and then "". The lang.xml file containing the most specific match will be used.

Note Note

To simplify debugging of lang.xml files, the Navigator example application included in the GeoBase SDK (accessible by navigating to Start | All Programs | Verizon Connect GeoBase Developer's Kit | Example Applications | Navigator) includes an 'English (US) - Debug Mode' language option. This setting is accessible by clicking the Settings menu option in the application and adjusting the 'Language:' dropdown list.

When set to 'English (US) - Debug Mode', errors in the lang.xml file located in the GeoBaseResources\langs\en-US folder (with the appropriate en-US Culture and Desc tags) will cause an exception to be thrown. When set to 'English (US)', errors in the xml file will be ignored (if possible).

Announcements

Announcements, in GeoBase, use lang.xml to generate a "sentence" where each "word" is the name of a '.wav' file, which resides in the same directory as lang.xml. GeoBase starts by fetching a Phrase node prefixed with "gb_" in the Announcements/Phrases node. Strings are added immediately to the "sentence", while other nodes result in GeoBase looking up other nodes in the Announcements section.

Possible nodes:

  • GetPhrase - copies the results of another Phrase, taken from the Phrase attribute

  • LookupGroup - uses a node in the Groups section to turn a value into a string, the value is taken from the From attribute

  • GetString - gets a string directly from the From attribute

Any of these nodes may have a Prefix or Suffix attribute, or both. These are added only if the node generates a string that isn't empty.

Sentences can also be constructed using an either/or syntax using the OnlyIfPresent and SuppressIfPresent attributes. For example, the following, taken from the Directions section, will choose either "gb_after_street" or "gb_after_dist" depending on the object's property/field "PrevStreet".

XML
<Phrase Id="gb_make_uturn">
  Make a U-turn <GetPhrase Phrase="gb_after_street" OnlyIfPresent="PrevStreet"/><GetPhrase Phrase="gb_after_dist" SuppressIfPresent="PrevStreet"/>
</Phrase>

LookupGroup

  • The Group attribute points to the group to look the value up in. Note, however, that this may be absent if there is only one Group with a name that matches the type of the value being looked up.

  • The Selector attribute may be set to FirstMatch if the group type is Regexp (see section below) - used when there is an array of values to describe and the requirement is just to describe the first one matching a regular expression.

  • The Optional attribute may be set to "True" if there is no value to describe (for example after taking an exit from a freeway there might be no subsequent turn to make, and so the TurnDirection property might be absent).

Group types

There are two special group types: Digitexp, and Regexp.

Digitexp - this group type uses simple digit matches to describe numbers. For example:

XML
<Digitexp Pattern="0">0</Digitexp>
<Digitexp Pattern="0X"><Digitmatch Val="d"/></Digitexp>
<Digitexp Pattern="0XX"><Digitmatch Val="dd"/></Digitexp>
<Digitexp Pattern="1">1</Digitexp>
<Digitexp Pattern="XXXX"><Digitmatch Val="Dxxx"/> 1000 <Digitmatch Val="ddd"/></Digitexp>
  • Children are Digitexp nodes with a Pattern attribute.

  • An "X" is used to match any digit.

  • Other allowed values are 0 to 9, comma, and a period (full-stop).

If more than one Pattern matches, the one with the fewest X's is selected. If the node has a Digitmatch child then a new value is looked up within the same group. The new value is generated from the Val attribute.

  • x means ignore that digit.

  • D means include that digit.

  • d means include that digit, but if Val is just d's and x's and the resulting value is 0 then it is not looked up.

  • 0-9 means add the specified digit.

  • Lookup attribute may be set to "False", in which case the resulting value is just used rather than being looked up again.

Regexp - this group type uses regular expressions to describe values. For example:

XML
<String Id="DistanceString" Type="Regexp">
  <Regexp Order="0" Pattern="1/4 mi">q_mile</Regexp>
  <Regexp Order="1" Pattern="1/2 mi">h_mile</Regexp>
  <Regexp Order="2" Pattern="3/4 mi">tq_mile</Regexp>
  <Regexp Order="3" Pattern="^1 mi">1 mile</Regexp>
  <Regexp Order="4" Pattern="(?&lt;number&gt;[0-9\.]+) mi"><Match Id="number" Group="Number"/> miles</Regexp>
  ...
  ...
</String>

The children are Regexp nodes.

The Order attribute dictates the order in which matches are attempted.

The Pattern contains the regular expression (which must be escaped to conform to XML requirements for example the 'greater than' symbol, ">", must be "&gt;").

The From attribute is used when the value has multiple properties and we just want to use one of them as the input to the match test.

The Regexp node may include Match (see below) nodes or other node types.

The Match node has an Id attribute, which refers back to any group naming in the regular expression.

A Group attribute causes the value to be looked up in the specified Group.

A SplitInto="Letters" attribute causes a string to be split into separate letters.

Strings

The Strings section is similar to the announcements section except that there is an optional "NoSuffixSpace" attribute. By default, spaces are added after each node, but if this is set to "True", then no space is added after the node. This means that:

XML
<Digitexp Pattern="X"><Digitmatch Val="D" Lookup="False" NoSuffixSpace="True"/>h</Digitexp>

will result in strings such as "5h" instead of "5 h".

Directions

The Directions section, used in the construction of driving directions, is similar to that of the announcements and string sections.