Localization of Metasys enumerations - Metasys - LIT-12013522 - Software Application - Basic Services client library for .NET (and COM) - Metasys API - 4.2

Metasys REST Client for .NET and COM Developer Guide

Product name
Basic Services client library for .NET (and COM)
Metasys API
Document type
API Reference Guide
Document number
Revision date
To get the client to return enumerations in the language of your choice, you must specify the culture when you create the client, or set the culture property before you use the Get methods. For an example, see the following code:
client.Culture = new CultureInfo("en-US");

The default language of the client machine is the CultureInfo.CurrentCulture property. For more information, refer to the Microsoft .NET library https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=netframework-4.8. For more information on the localization languages supported by Metasys client, see Supported localization languages.

The Metasys server returns enumerations values in a format similar to the "reliabilityEnumSet.reliable" string. If the client library supports the specified language, the MetasysClient object has a method that converts these values into human readable strings using the specified language of the CultureInfo object.
Note: If a translated value, for example, Variant.StringValue contains an enumeration value and not a translated string, it might indicate an issue with the setup of the globalization of the MetasysClient object.
If you want the enumeration key rather than the translated value, use the EnumerationKey attribute. For example, the translated value of Reliability property of Variant object has the enumeration key under the attribute: ReliabilityEnumerationKey. For a translated value example see the following Variant object:
Variant property = client.ReadProperty(objectId, "presentValue");
    "StringValue": "72",
    "StringValueEnumerationKey": null,
    "NumericValue": 72.0,
    "BooleanValue": true,
    "ArrayValue": null,
    "Attribute": "presentValue",
    "Id": "f1469e25-c46c-5009-b92e-d82603e742a4",
    "Reliability": "Reliable",
    "ReliabilityEnumerationKey": "reliabilityEnumSet.reliable",
    "Priority": "0 (No Priority)",
    "PriorityEnumerationKey": "writePriorityEnumSet.priorityNone",
    "IsReliable": true
Use the following two methods of the MetasysClient class for the localization of enumerations:
  • Localize: localization of enumerations from the client object.
  • ResourceManager.Localize: localization of enumerations without instantiating a client.
The following .NET C# code is an example of successful enumeration localization:
// Access from the client object (uses client.Culture as input)
string translated = client.Localize("reliabilityEnumSet.reliable");
// Access without instantiating a client
translated = ResourceManager.Localize("reliabilityEnumSet.reliable",
  new CultureInfo("it-IT"));