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.
Localized alarm text messages
Moderator: uasdknet
- Support Team
- Hero Member
- Posts: 3064
- Joined: 18 Mar 2011, 15:09
Re: Localized alarm text messages
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:
Initialize event:
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")
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
Unified Automation Support Team
- baldo
- Hero Member
- Posts: 25
- Joined: 19 Nov 2019, 12:15
Re: Localized alarm text messages
It worked! Thank you