FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.36k stars 658 forks source link

[HELP] How to add locale into LocalizedText ? #881

Open YiKai07 opened 5 years ago

YiKai07 commented 5 years ago

Hi, I have been looking for a function to add local into LocalizedText, but I only found localid in OPC specification part 3, and I also try to add

<ListOfLocalizedText>
        <LocalizedText>
            <locale>en</locale>
            <Text>Running</Text>  
        </LocalizedText>
        .....
</ListOfLocalizedText>

into my xml file and import into my code, but it still dosen't work.

and I also try this code found in the example:

def enum_to_stringlist(a_enum):
    items = []
    for value in a_enum:
        items.append(ua.LocalizedText(value.name))
    return items

but ua.LocalizedText only take one value, and if I gave a String like "en, Running", it will output like "", "en, Running"

and the correct LocalizedText should be like "en", "Running"

oroulet commented 5 years ago

As written in readme, this is one of the things not implemented. But this should probably be easy. It is just that I had (and still have) absolutely no idea about what people expect from this locale stuff. How do you think this should work?

-------- Original Message -------- On Sep 2, 2019, 04:45, YiKai07 wrote:

Hi, I have been looking for a function to add local into LocalizedText, but I only found localid in OPC specification part 3, and I also try to add

en Running .....

into my xml file and import into my code, but it still dosen't work.

and I also try this code found in the example:

def enum_to_stringlist(a_enum): items = [] for value in a_enum: items.append(ua.LocalizedText(value.name)) return items

but ua.LocalizedText only take one value, and if I gave a String like "en, Running", it will output like "", "en, Running"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

YiKai07 commented 5 years ago

I'm still looking for solution, so I've no idea how to work this either. seems like add Locale from xml file it's worked, but I haven't get the correct output yet.

maxim-s-barabash commented 5 years ago

The OPC UA client must explicitly provide the OPC UA specific language "LocaleId" to change the alarm texts. UaExpert provided the OPC UA specific "LocaleId" as value for the parameter "General.LocaleId".

On server side process ua.ActivateSessionParameters.LocaleIds

...