Localized alarm text messages

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Localized alarm text messages

Post by baldo »

Hi,

https://forum.unified-automation.com/viewtopic.php?f=18&t=637 same question as this one, but for .NET sdk:

I have a question about localized strings in OPC UA server, especially alarm messages.
When the client connects to the OPC UA server, in the session there should be also an information about localization (en, fr, de,....).
Is it possible to send an event to the client with localized text based on the localization set in the session?
C# stack has some "resource manager" which should take care of this, but looks like the SDK doesn't translate automatically my messages when I call ReportEvent. Also if I try doing it calling manually ResourceManager.Translate I don't succeed because I have no information about the session's preferred locales.

User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Re: Localized alarm text messages

Post by baldo »

up

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Localized alarm text messages

Post by Support Team »

Hello,

ResourceManager.Translate is called implicitly for event fields with DataType LocalizedText. You do not have to call it manually.

You need to add the translations to the ResourceManager and set the value at the event.

Add to ResourceManager:

Code: Select all

            Server.ResourceManager.Add("ID_Event", "en-US", "The Event");
            Server.ResourceManager.Add("ID_Event", "de-DE", "Das Ereignis")
Initialize event:

Code: Select all

            GenericEvent e = new GenericEvent(Server.FilterManager);
            e.Initialize(
                null,
                new NodeId(UnifiedAutomation.TestServer.ObjectTypes.TestEventType, m_nodeSetNs),
                new NodeId(UnifiedAutomation.TestServer.Objects.Events, m_nodeSetNs),
                UnifiedAutomation.TestServer.BrowseNames.Events,
                EventSeverity.Medium,
                new LocalizedText("ID_Event", "en-US", "The Event"));
Best regards
Unified Automation Support Team

User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Re: Localized alarm text messages

Post by baldo »

It worked! Thank you

Post Reply