From 3127fdb8cc73e36f0c0909f29d62b7f6131b420e Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Thu, 11 Sep 2025 19:14:06 +0200 Subject: [PATCH] localizationChecker: Added metatable instead of hardcoded table entry list to improve maintainability --- .github/scripts/localizationChecker.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/scripts/localizationChecker.py b/.github/scripts/localizationChecker.py index bcca72ae..9c9ac8a5 100644 --- a/.github/scripts/localizationChecker.py +++ b/.github/scripts/localizationChecker.py @@ -60,21 +60,15 @@ def addUpdatedTables(languageCode, dlc): if dlc != "ab+": # Add language table lua.execute('EID.descriptions["'+languageCode+'"] = {}') - # Add all tables that are assumed to exist already in ab+ - updatedTables = ["collectibles", "cards", "trinkets", "ConditionalDescs"] - if dlc == "rep": - updatedTables += ["pills", "carBattery", "BFFSSynergies", "CharacterInfo", "ConditionalDescs", "VoidNames", "custom"] - if dlc == "rep+": - updatedTables += ["abyssSynergies", "horsepills", "tarotClothBuffs", "bookOfVirtuesWisps", "goldenTrinketEffects"] - # korean uses some additional addititve tables - if languageCode == "ko_kr": - if dlc == "rep": - updatedTables += ["dice", "MCM"] - else: - updatedTables += ["bookOfVirtuesWisps"] - for table in updatedTables: - lua.execute('EID.descriptions["'+languageCode+'"].'+table+' = {}') + # Add metatable to create missing tables on the fly + lua.execute('setmetatable(EID.descriptions["'+languageCode+'"], {\ + __index = function(tbl, key)\ + local newTbl = {}\ + rawset(tbl, key, newTbl)\ + return newTbl\ + end\ + })') # find entries in table2 that are missing or different than in table 1 def compare_tables(table1, table2, prev_key):