GenoPro Home
GenoPro Home  |  SDK Home  |  Report Generator  |  Support  |  Search  |  Help  |  Site Map

Skip Navigation Links.

NameDictionary Class

The NameDictionary class is similar to the LanguageDictionary object, however it is specialized to translate names from one language to another. If you are reading this page, it is because you have followed a link from the support form or from within the file NameDictionary.xml in the report template.

At the moment, the NameDictionary object has only three methods:

BuildLookupTable

BuildLookupTable(strFileNameDictionary, strLanguageFrom, strLanguageTo)

Builds the lookup table by loading an XML file into memory and finding all elements containing both references to the From and To language. The following sample of code shows how to build a lookup table to translate English names into Japanese.

Set oNameDictionary = Util.NewNameDictionary
oNameDictionary.BuildLookupTable "NameDictionary.xml", "EN", "JA"

Report.WriteFormattedBr "<br><br>Name: Daniel is {&t} in Japanese", oNameDictionary("Daniel")

Lookup

This is the default property of the NameDictionary object. This property returns the translated name, if any, otherwise returns the original name.

 

Peek

This property is very similar to Lookup, however it returns an empty string if the name is not found in the dictionary.

Example:

Report.WriteFormattedBr "<br><br>Name: Daniel is {&t} in Japanese", oNameDictionary.Peek("Daniel")

 

Tips

You should store the object oNameDictionary into the Session object so it is accessible from any page in the report.

Session("oNameDictionary") = oNameDictionary

You are welcome to use the method Util.FirstNonEmpty to give priority to a name. For instance, if you want to display the Japanese name, but if that fails display the nick name before the first name, then you could use the following code:

Set oNameDictionary = Session("oNameDictionary")
strName = Util.FirstNonEmpty(oNameDictionary.Peek(i.Name.First), i.Name.Nick, i.Name.First, i.Name)
 

Copyright © 1998-2024. All rights reserved. GenoPro® and the GenoPro logo are registered trademarks.