fix: translate also walltypes

This commit is contained in:
Niklas 2023-03-16 01:56:44 +01:00
parent 212606febd
commit e31e09d589
2 changed files with 27 additions and 20 deletions

View File

@ -1,27 +1,33 @@
import json import json
todo_types = ["roomitemtypes", "wallitemtypes"]
# Create a dictionary mapping classname to name and description # Create a dictionary mapping classname to name and description
furniture_dict = {} furniture_dict = {}
with open('gamedata/furnidata.json', 'r', encoding='utf-8') as f: with open('gamedata/furnidata.json', 'r', encoding='utf-8') as f:
furniture_data = json.load(f) furniture_data = json.load(f)
for furnitype in furniture_data['roomitemtypes']['furnitype']: for todo_type in todo_types:
for furnitype in furniture_data[todo_type]["furnitype"]:
classname = furnitype['classname'] classname = furnitype['classname']
furniture_dict[classname] = { furniture_dict[classname] = {
"name": furnitype['name'], "name": furnitype['name'],
"description": furnitype['description'], "description": furnitype['description'],
} }
orig_furniture_data = {}
# Load the JSON file # Load the JSON file
with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f: with open('../assets/gamedata/FurnitureData.json', 'r', encoding='utf-8') as f:
furniture_data = json.load(f) orig_furniture_data = json.load(f)
# Replace the name and description values with values from the XML file # Replace the name and description values with values from the XML file
for furnitype in furniture_data['roomitemtypes']['furnitype']: for todo_type in todo_types:
for furnitype in orig_furniture_data[todo_type]["furnitype"]:
classname = furnitype['classname'] classname = furnitype['classname']
if classname in furniture_dict: if classname in furniture_dict:
furnitype['name'] = furniture_dict[classname]['name'] furnitype['name'] = furniture_dict[classname]['name']
furnitype['description'] = furniture_dict[classname]['description'] furnitype['description'] = furniture_dict[classname]['description']
# Save the updated JSON file # Save the updated JSON file
with open('../assets/gamedata/FurnitureData.json', 'w') as f: with open('../assets/gamedata/FurnitureData.json', 'w') as f:
json.dump(furniture_data, f, separators=(',', ':')) json.dump(orig_furniture_data, f, separators=(',', ':'))

View File

@ -1,13 +1,14 @@
import json import json
# Habbo Furni Translator by giu888 todo_types = ["roomitemtypes", "wallitemtypes"]
# Load the JSON data from the file # Load the JSON data from the file
with open("../assets/gamedata/FurnitureData.json", encoding='utf-8') as f: with open("../assets/gamedata/FurnitureData.json", encoding='utf-8') as f:
data = json.load(f) data = json.load(f)
with open("catalog_items.sql", "w", encoding='utf-8') as f: with open("catalog_items.sql", "w", encoding='utf-8') as f:
for furni in data["roomitemtypes"]["furnitype"]: for todo_type in todo_types:
for furni in data[todo_type]["furnitype"]:
furni_id = furni["id"] furni_id = furni["id"]
if furni["name"]: if furni["name"]:
furni_name = furni["name"].replace("'", "''").strip()[:55] furni_name = furni["name"].replace("'", "''").strip()[:55]