Page 1 of 1

Localized alarm text messages

Posted: 11 Mar 2021, 20:20
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.

Re: Localized alarm text messages

Posted: 30 Apr 2021, 08:33
by baldo
up

Re: Localized alarm text messages

Posted: 30 Apr 2021, 10:42
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"));

Re: Localized alarm text messages

Posted: 21 May 2021, 12:33
by baldo
It worked! Thank you