C# Class Sage.ResourceManagement.DictionaryFile

Provides a base class for use with dictionary and settings translation.
The Sage localization framework uses xml 'dictionaries' that contain locale-specific values which at translation time get inserted at desired locations in XML configuration files. This class, provided a file path template, opens all dictionaries applicable for a locale, and combines the localization 'items' into a single document, prioritizing them as defined in the configuration of that locale.

A locale (la in this example, which stands for Latin America) is typically defined like this:

<locale name="la" dictionaryNames="es-LA,es,en" resourceNames="es-LA,es,default"/> This means that, when processing la locale the dictionaries to be used for translation should be used in priority order as specified with dictionaryNames. The most specific dictionary, with highest priority, is in this case 'es-LA', or Spanish for Latin America. Next one is es or Spanish, and finally en or English.

This class will attempt to open and combine entries from all three dictionaries. The base dictionary for all locales is the en dictionary. Entries defined in dictionaries with higher priority will override any previously defined entries.

Example:
In this example, there are three dictionaries, with some of the entries defined in more than one dictionary. Observe how the dictionaries are combined in the resulting file:
en.xml:
<intl:dictionary> <intl:phrase id="training.titles.products">Products</intl:phrase> <intl:phrase id="training.titles.home">Home</intl:phrase> <intl:phrase id="training.titles.athletes">Athletes</intl:phrase> </intl:dictionary
es.xml:
<intl:dictionary> <intl:phrase id="training.titles.products">Productos</intl:phrase> <intl:phrase id="training.titles.athletes">Los atletas</intl:phrase> </intl:dictionary
es-LA.xml:
<intl:dictionary> <intl:phrase id="training.titles.products">Los deportistas</intl:phrase> </intl:dictionary
Resulting document:
<intl:dictionary> <intl:phrase id="training.titles.products" source="es">Productos</intl:phrase> <intl:phrase id="training.titles.home" source="en">Home</intl:phrase> <intl:phrase id="training.titles.athletes" source="es-LA">Los deportistas</intl:phrase> </intl:dictionary
ファイルを表示 Open project: igorfrance/sage

Public Methods

Method Description
DictionaryFile ( SageContext context, string locale ) : System

Initializes a new instance of the DictionaryFile class, using the specified context and locale.

Private Methods

Method Description
CombineVariations ( ) : XmlDocument

Method Details

DictionaryFile() public method

Initializes a new instance of the DictionaryFile class, using the specified context and locale.
public DictionaryFile ( SageContext context, string locale ) : System
context SageContext The to use for loading resources and resolving paths.
locale string The locale within the specified context's category that this is /// used for.
return System