ANSI C Based OPC UA Client/Server/PubSub SDK
1.9.1.442
|
OPC UA provides localization of text provided by an OPC UA server.
The DataType that is used for this feature is the LocalizedText structure that consist of a LocaleId and a localized text string.
The LocalizedText is provided for Node Attributes like DisplayName and Description, for Variable Values with DataType LocalizedText or for Event fields like the Event Message. See Base Node Class for more details.
The OPC UA client selects the language(s) of interest by specifying a LocaleId array for the Session created with a server.
The server provides the supported LocaleIds in the Variable Server > ServerCapabilities > LocaleIdArray. The server may support more languages but it would be good to expose at least the default language.
The server returns one of the requested languages if supported. If none of the client requested language is supported the server returns the default language.
The language provided to the client is always part of the LocalizedText DataType. Therefore the client knows the returned language even if the server does not support one of the requested languages.
The default implementations provided with the SDK are only able to manage one language for places where LocalizedText is handled.
If a server implementation want to manage more than one (default) language, the server implementation need to check Read and Browse results and provide a translation if required based on the Session settings.
The following sample code shows such handlers added to corresponding SDK demo server functions. The extensions are marked with 'Code added for LocalizedText handling'.
The following code shows the extended handling for the Browse Service. The helper function checkTranslation() is described below in Helper function.
The following code shows the extended handling for the Read Service. The helper function checkTranslation() is described below in Helper function.
The translation of Event fields can be done through implementation of the callback function UaServer_pfServer_TranslateEventField. The callback can be registered with UaServer_SetCallback_TranslateEventField().
The helper function used in the sample code above: