Nevron Open Vision Documentation
Localization Dictionaries

All localization requests of Nevron Open Vision based applications are handled by the single instance of the NLocalizationDictionary singleton class available through its Instance static read only field.

Localization Dictionaries

The localization dictionary is a data structure used to store and obtain translations of strings. A localization dictionary contains a map of keys and their translations. To set the translation of a given key, you can use the SetTranslation method of the dictionary.

Set a term translation
Copy Code
NLocalizationDictionary.Instance.SetTranslation("Cancel", "Отказ");

To get the translation of a given key you can use the NLoc.Get shortcut method like this:

Get a term translation
Copy Code
string localizedString = NLoc.Get("Cancel");

The NLoc.Get method returns the translation of the given key or the key itself if a translation for it is not found in the dictionary.

Alternatively to get the translation of a given key, you can use the TryGetTranslation method of the localization dictionary. This method returns true if a translation of the given key is found in the dictionary and false otherwise. The translation itself is returned as an out parameter.

If you are writing an application that should be localized to different languages, you should encapsulate all string literals subject to localization in NLoc.Get() calls as shown in the example above.
Loading, Editing and Saving Dictionaries

Nevron localization dictionaries can be loaded from and save to TMX (translation memory exchange format). To load and save dictionaries, use the LoadFromStream and SaveToStream methods of the localization dictionary.

The following code shows how to load a Nevron Localization dictionary from file:

Load Localization Dictionary
Copy Code
using (Stream stream = NFile.OpenRead(@"C:\MyApp\Languages\Bulgarian.tmx"))

Similarly you can save a dictionary to a file:

Save Localization Dictionary
Copy Code
using (Stream stream = NFile.Create(@"C:\MyApp\Languages\Bulgarian.tmx"))

Nevron provides a dictionary editor application, which can be used to import all localizable strings from one or more C# solutions, projects or source code files, edit the translations and save the result to a TMX file ready to be loaded in your application. The Nevron Dictionary Editor can be downloaded from Nevron's website.

See Also
Send Feedback