Is there a way to easily export the Translation manager and edit those files so i can send them to a translator that does not have experience in XML or so?
I already tried Excel but i cant even import the xml.
Are there some people that had the same issues, that have a tool they could recommend or something.
The issue already was there in 2016 regarding:
I hope there are better solutions available 8 years later?
Optimally a CSV export/import would be pretty useful i think.
I build it myself with scripts and that works great.
Its essentially so i can send just one file to a translation bureau and they can easily add all the languages i need in excel or other format where they have experience in.
I'm hoping to add a translation bundle import/export tool that works with Ignition's somewhat odd format to Kindling, the semi-official GUI tool I created to work with Ignition files.
It would also be good to add first-party support to Ignition, obviously; the entire translation management system needs some attention. It's on our list to get to, but hasn't risen to the top of the pile yet.
Nice to hear you are looking into the translation manager!
an example of the CSV:
Key,es,zh,en,nl
Menu Item 2,Elemento de Menú 2,菜单项 二,Menu Item 2,Menu Item 2
Dutch,Holandés,荷兰语,Dutch,Nederlands
So if i want to add another language i just put the language code after the last in the header and then adjust it, but that works easily in Excel for example.
My script to export CSV:
def runAction(self, event):
import csv
from com.inductiveautomation.ignition.gateway import IgnitionGateway
# Get the localization manager
localization_manager = IgnitionGateway.get().getLocalizationManager()
# Load the full translation package
translation_package = localization_manager.loadFullPackage()
# Get all translation keys
keys = translation_package.getAvailableKeys()
# Collect all available languages
all_languages = set()
for key in keys:
translations = translation_package.getTranslationsFor(key)
all_languages.update(translations.keys())
# Define the CSV file path
csv_file_path = "filepath"
# Write to CSV
with open(csv_file_path, mode='w') as file:
writer = csv.writer(file, lineterminator='\n')
# Create header row
header = ["Key"] + list(all_languages)
writer.writerow(header)
# Write translation rows
for key in keys:
translations = translation_package.getTranslationsFor(key)
row = [key] + [translations.get(lang, '') for lang in all_languages]
writer.writerow(row)
print("Export successful!")
And import back to the translationmanager:
import system.util
import io
# Define the CSV file path
csv_file_path = "filepath"
# Read from CSV and update translations
with io.open(csv_file_path, mode='r', encoding='utf-8-sig') as file:
# Read all lines
lines = file.readlines()
# Split the lines into headers and rows
headers = lines[0].strip().split(',')
system.perspective.print("CSV Headers: " + str(headers))
if 'Key' not in headers:
system.perspective.print("Error: 'Key' column not found in CSV file.")
return
languages = headers[1:] # Get languages from the header row
system.perspective.print("Languages found: " + str(languages))
for line in lines[1:]:
try:
row = line.strip().split(',')
key = row[headers.index('Key')]
translations = {lang: row[headers.index(lang)] for lang in languages if row[headers.index(lang)]}
for lang, translation in translations.items():
try:
system.util.modifyTranslation(key, translation, lang)
except Exception as e:
system.perspective.print("Error adding translation for {key} in {lang}: {e}")
except Exception as e:
system.perspective.print("Error processing row: {e}")
system.perspective.print("Import successful!")
*I am not an expert in Ignition, but this works as expected