EnumString and multiple locales|OPC UA Standard|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
EnumString and multiple locales
Avatar
Balint Balint
Member
Members
Forum Posts: 3
Member Since:
02/23/2023
sp_UserOfflineSmall Offline
1
02/23/2023 - 06:17
sp_Permalink sp_Print

Hello, I am an OPC UA newbie. I would like to have an enum, where the values have different names, based on the current locale.

My understanding of the enums is this: Enum Data Types have an EnumString property, containing a list of LocalizedTexts. Using the enum variable’s numeric value as the index of this list, the variable’s named value can be found. E.g. EnumString = [“en|On”, “en|Off”, “en|Starting”] and the variable’s value is 1, then the named value is “en|Off”. 

Questions:

a) Can the values of the EnumString contain texts for multiple locales somehow? E.g. [“en|On;de|Ein”, “en|Off;de|Aus”, “en|Starting;de|Startet”] and if the variable’s value is 1, then the named value is “en|Off” or “de|Aus” depending on the current locale?

b) If this is not possible, what is the point of having localized texts in the enum’s definition?

c) Is the sitation the same when using EnumValues instead of EnumStrings?

 

Thanks!

Avatar
Randy Armstrong
Admin
Forum Posts: 1578
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/23/2023 - 09:10
sp_Permalink sp_Print

When a session is created the client provides its preferred locales.

All LocalizedTexts returned use the preferred locales for the Session.

So a Session that asked for “de” would get “de” LocalizedTexts if they are available.

The value of the enum is not affected by the exact text that is returned for EnumString and no programmatic comparisons can be done with LocalizedTexts. The numeric value must always be used.

Avatar
Balint Balint
Member
Members
Forum Posts: 3
Member Since:
02/23/2023
sp_UserOfflineSmall Offline
3
02/23/2023 - 23:19
sp_Permalink sp_Print

Thank you for your response. What you describe is exactly what I expected and what I need.

The problem is, that the LocalizedText seems to be a single locale-text pair, one locale and one text, not various translations of the given string.  And if the LocalizedText can only hold a single string, how would the server know what are its translations? 

Or did I miss something, and can a LocalizedText hold multiple translations?

https://reference.opcfoundatio…..4/docs/8.5

Avatar
Balint Balint
Member
Members
Forum Posts: 3
Member Since:
02/23/2023
sp_UserOfflineSmall Offline
4
02/24/2023 - 03:08
sp_Permalink sp_Print

In the meanwhile I realized the root of my confusion. I mixed together client and server side representations.

– LocalizedText is meant for the client, who only needs 1 string and the additional information, which language does it have. 

– How exactly the various translations are configured and stored in the server, that is a server specific detail, and does not need to follow the LocalizedText’s structure.  

Avatar
Randy Armstrong
Admin
Forum Posts: 1578
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
5
02/24/2023 - 06:51
sp_Permalink sp_Print sp_EditHistory

https://reference.opcfoundatio…..s/5.10.4.1

If a Server allows writing of Attributes with the DataType LocalizedText, the Client can add or overwrite the text for a locale by writing the text with the associated LocaleId. Writing a null String for the text for a locale shall delete the String for that locale. Writing a null String for the locale and a non-null String for the text is setting the text for an invariant locale. Writing a null String for the text and a null String for the locale shall delete the entries for all locales. If a Client attempts to write a locale that is either syntactically invalid or not supported, the Server returns Bad_LocaleNotSupported. The Write behaviour for Value Attributes with a LocalizedText DataType is Server specific but it is recommended to follow the same rules.

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