Hello!
I am trying to do translation on the fields in a row selector object. The display text does not update automatically if you add the terms into the translation manager.
The Data In property for the row selector is hard-coded. One solution is to create two hard-coded dataset properties (one for English and one for Portuguese) and use an expression binding that switches between those two datasets. This would work fine but I would prefer to not hard-code any translations. I wanted to have all of the translations in the translation manager so they would be in one place.
Currently, I have a script that runs upon opening the vision window that loops through and translates every cell in an English dataset and writes it to the Portuguese dataset. This works but I feel that it is not ideal. It also seems to not work great when previewing the screen in designer. I am including the script below. Any suggestions? Thanks!
def translateDataset(enData):
headers = ["Line", "Equipment", "FilterString"]
data = []
for row in range(enData.getRowCount()):
data.append([system.util.translate(enData.getValueAt(row, 0)), system.util.translate(enData.getValueAt(row, 1)), system.util.translate(enData.getValueAt(row, 2))])
ptData = system.dataset.toDataSet(headers, data)
return ptData
enData = system.gui.getParentWindow(event).getComponentForPath('Root Container.Group 2').EnglishAlarmGroups
system.gui.getParentWindow(event).getComponentForPath('Root Container.Group 2').PortugueseAlarmGroups = translateDataset(enData)