Localization Status

I have a project that has both English and Spanish in it. I have been able to use the translation manager to translates items on the screen to Spanish using the Language Selector. However. I am sending a lot of strings from the PLC. I would like in the PLC to have a table of English strings and Spanish strings and send the appropriate ones. The problem is that the PLC does not know the current status of the language selector. Is there a way to tie the selected language status (English or Spanish) of the language selector to a tag I can read in the PLC?

Thanks

You can use the selectedLocale property of the Language Selector. It’s read-only, but it should do what you’re asking for. (docs)

Also remember that if you’re using those strings from the PLC in scripts or expressions in the client scope, you can translate them without them being on the screen. Check out system.util.translate and the translate expression. In an upcoming version of Ignition we’ll be bringing the expression function into gateway scope as well.

I saw the selectedlocal property in the docs, but it does not show up in the property editor, so I don’t know how to bind it to a tag.

I think you’d need to script a property change handler.

I right clicked on the component, chose ‘scripting’, chose the ‘propertyChange’ event handler, and chose the Script Editor tag. My sample script (just to show it works) is:

if event.propertyName == 'selectedLocale':
  print event.oldValue, event.newValue

Obviously you’d need to write to a tag instead. Be sure to check the propertyName of the event, since all events will trigger this script. You’ll also need to think through your logic if you’re writing to a gateway tag and have more than one client open with this language selector.

Got it! Thank you.

1 Like