Yes, that was the solution.
A simple Python script that reorders the texts.xml according to my necessity works just fine. The Designer picks up the updated texts.xml file with the new ordering.
Below is the code if someone needs it in the future.
import xml.etree.ElementTree as ET
from xml.dom import minidom
def reorder_languages(input_file, output_file):
"""
Reorders languages and translations from GB, IT, FR, ESP to IT, GB, ESP, FR
"""
# Define the new order
new_order = ['IT', 'GB', 'ESP', 'FR']
# Parse the XML file
tree = ET.parse(input_file)
root = tree.getroot()
# Find and reorder Languages section
languages = root.find('Languages')
if languages is not None:
# Get all Language elements
lang_elements = list(languages.findall('Language'))
# Create a dictionary for easy lookup
lang_dict = {elem.get('Id'): elem for elem in lang_elements}
# Clear existing languages
languages.clear()
# Add languages in new order
for lang_id in new_order:
if lang_id in lang_dict:
languages.append(lang_dict[lang_id])
# Find and reorder Translations in all Text elements
texts = root.find('Texts')
if texts is not None:
for text_group in texts.findall('.//TextGroup'):
for text in text_group.findall('Text'):
# Get all Translation elements
translations = list(text.findall('Translation'))
# Create a dictionary for easy lookup
trans_dict = {elem.get('Language'): elem for elem in translations}
# Clear existing translations
for trans in translations:
text.remove(trans)
# Add translations in new order
for lang_id in new_order:
if lang_id in trans_dict:
text.append(trans_dict[lang_id])
# Convert to string with proper formatting
xml_str = ET.tostring(root, encoding='utf-8')
# Pretty print
dom = minidom.parseString(xml_str)
pretty_xml = dom.toprettyxml(indent=" ", encoding='utf-8')
# Remove extra blank lines
lines = pretty_xml.decode('utf-8').split('\n')
lines = [line for line in lines if line.strip()]
# Write to output file
with open(output_file, 'w', encoding='utf-8') as f:
f.write('\n'.join(lines))
print(f"Successfully reordered languages in {output_file}")
print(f"New order: {' -> '.join(new_order)}")
if __name__ == "__main__":
# Usage
input_file = "texts.xml"
output_file = "output.xml" # Change to your desired output file name
reorder_languages(input_file, output_file)