12/06/2021
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:
- 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?
- Is there an easier way to achieve this?
Any help at all would be appreciated, thank you.
05/30/2017
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.
1 Guest(s)