Implementing localized browse names|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Implementing localized browse names
Avatar
EG
Member
Members
Forum Posts: 35
Member Since:
12/06/2021
sp_UserOfflineSmall Offline
1
12/16/2021 - 02:41
sp_Permalink sp_Print

I have created a node and set the DisplayName to a LocalizedText with the Key property as a string that I am able to translate. I am trying to find a way that when a client browses this node, the display name will be returned to them in the clients preferred locale.

Here’s what I tried:

  • Overriding CreateResourceManager on my subclass of StandardServer, then returning a subclass of ResourceManager that overrides the Translate methods, and then performing the translation and returning a new LocalizedText object in the preferred locale.

    Result:
    This seems to work when emitting events, but does not work for node browsing.

  • Setting the OnReadDisplayName field of the node I have created, then use the ISystemContext.UserIdentity to find the preferred locale, and setting the LocalizedText reference to a new object with the preferred locale.

    Result:
    This seems to work when reading attributes of a node, but also does not work for node browsing.

I have dived into the codebase and looked at things like CustomNodeManager2.Browse, CustomNodeManager2.GetReferenceDescription, but I am really struggling to find a way to inject the localized text into the response.

The only chance I have seen would be to replace BinaryEncoder with a specialized BinaryEncoder that when WriteLocalizedText is called, it translates the text before writing to the output stream. This looks like quite a difficult task and it’s possible I will find some other blockers while doing it that prevents this working too (e.g. it is not immediately clear how I would determine what the preferred locale is at this point in the code).

Before I try to tackle this task, I hoped somebody would be able to provide some guidance or give me some insight:

  1. Is providing localized display names for browsed nodes a sensible idea? Or is the intention that display names on the browse nodes would always be in a single locale?
  2. Is there an easier way to achieve this?

Any help at all would be appreciated, thank you.

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
12/16/2021 - 21:39
sp_Permalink sp_Print

First, this type of question is better posted to GitHub:

https://github.com/OPCFoundati…..ETStandard

Second, you should never need to modify the serializers to do this. If you are modifying the base classes then you simply need to make some method virtual and provide logic that updates the localized text values after calling the base implementation.

Last, yes it is a good idea to provide localized display names. The expectation is users would see the best translation available for each node based on the the order of their preferred locales.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4891