Improved Translation Checker CI to display missing entries for each dlc file
This commit is contained in:
1 parent
ee5f90ee8f
commit
1cebbc95f3
1 file changed
+72
-32
@@ -50,6 +50,24 @@ def getMaxCheckLimit(parentName):
|
|||||||
return maxChecklimit[entry]
|
return maxChecklimit[entry]
|
||||||
return float('inf')
|
return float('inf')
|
||||||
|
|
||||||
|
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", "trinkets"]
|
||||||
|
if dlc == "rep":
|
||||||
|
updatedTables += ["cards", "pills", "carBattery", "BFFSSynergies", "CharacterInfo", "ConditionalDescs", "VoidNames", "custom"]
|
||||||
|
|
||||||
|
# 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+' = {}')
|
||||||
|
|
||||||
# find entries in table2 that are missing or different than in table 1
|
# find entries in table2 that are missing or different than in table 1
|
||||||
def compare_tables(table1, table2, prev_key):
|
def compare_tables(table1, table2, prev_key):
|
||||||
errorCount = 0
|
errorCount = 0
|
||||||
@@ -88,55 +106,77 @@ def compare_tables(table1, table2, prev_key):
|
|||||||
return errorCount
|
return errorCount
|
||||||
|
|
||||||
|
|
||||||
lua.execute('REPENTOGON = true; EID = {}; EID.descriptions = {}; function EID:updateDescriptionsViaTable(changeTable, tableToUpdate) for k,v in pairs(changeTable) do if v == "" then tableToUpdate[k] = nil else tableToUpdate[k] = v end end end')
|
languageProgress = {}
|
||||||
g = lua.globals()
|
en_us_entries = {}
|
||||||
|
|
||||||
# Read English language files first
|
|
||||||
englishFiles = []
|
|
||||||
for dlc in dlcs:
|
for dlc in dlcs:
|
||||||
englishFiles += glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/en_us.lua", recursive=True)
|
lua.execute('REPENTOGON = true; EID = {}; EID.descriptions = {}; function EID:updateDescriptionsViaTable(changeTable, tableToUpdate) for k,v in pairs(changeTable) do if v == "" then tableToUpdate[k] = nil else tableToUpdate[k] = v end end end')
|
||||||
|
g = lua.globals()
|
||||||
|
addUpdatedTables("en_us", dlc)
|
||||||
|
|
||||||
for englishFile in englishFiles:
|
# Read English language files first
|
||||||
|
englishFile = glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/en_us.lua", recursive=True)[0]
|
||||||
print("reading:", englishFile)
|
print("reading:", englishFile)
|
||||||
lua.execute(open(englishFile, "r", encoding="UTF-8").read())
|
lua.execute(open(englishFile, "r", encoding="UTF-8").read())
|
||||||
|
|
||||||
en_us_entries = count_entries(g.EID['descriptions']['en_us'])
|
en_us_entries[dlc] = count_entries(g.EID['descriptions']['en_us'])
|
||||||
print("en_us entries:", en_us_entries)
|
print("en_us "+dlc+" entries:", en_us_entries[dlc])
|
||||||
|
|
||||||
|
|
||||||
languages = {}
|
langFiles = []
|
||||||
langFiles = []
|
|
||||||
for dlc in dlcs:
|
|
||||||
if ONLY_DO_LANGUAGE != "":
|
if ONLY_DO_LANGUAGE != "":
|
||||||
langFiles += glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/"+ONLY_DO_LANGUAGE+".lua", recursive=True)
|
langFiles += glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/"+ONLY_DO_LANGUAGE+".lua", recursive=True)
|
||||||
else:
|
else:
|
||||||
langFiles += glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/*.lua", recursive=True)
|
langFiles += glob.glob(SOURCE_MOD_DIRECTORY+"/**/"+dlc+"/*.lua", recursive=True)
|
||||||
# Read other language files
|
# Read other language files
|
||||||
for file in langFiles:
|
for file in langFiles:
|
||||||
if "en_us" not in file and "transformations" not in file:
|
if "en_us" not in file and "transformations" not in file:
|
||||||
print("reading:",file)
|
languageCode = os.path.basename(file).replace(".lua","")
|
||||||
lua.execute(open(file, "r", encoding="UTF-8").read())
|
print("reading:",file)
|
||||||
languages[os.path.basename(file).replace(".lua","")] = 0
|
addUpdatedTables(languageCode, dlc)
|
||||||
|
lua.execute(open(file, "r", encoding="UTF-8").read())
|
||||||
|
if languageCode not in languageProgress:
|
||||||
|
languageProgress[languageCode] = {}
|
||||||
|
|
||||||
# Evaluate all languages
|
# Evaluate language for completeness
|
||||||
for lang in languages:
|
print(f"Evaluating language '{languageCode}'..")
|
||||||
print(f"Evaluating language '{lang}'..")
|
errorCount = compare_tables(g.EID['descriptions']['en_us'], g.EID['descriptions'][languageCode], languageCode+"("+dlc+")")
|
||||||
errorCount = compare_tables(g.EID['descriptions']['en_us'], g.EID['descriptions'][lang], lang)
|
percentage = (en_us_entries[dlc] - errorCount) / en_us_entries[dlc] * 100
|
||||||
percentage = (en_us_entries - errorCount) / en_us_entries*100
|
languageProgress[languageCode][dlc] = [percentage, errorCount]
|
||||||
languages[lang] = [percentage, errorCount]
|
print(f"{Red}Errors found: {errorCount} / {en_us_entries[dlc]}{Color_Off}\n\n")
|
||||||
print(f"{Red}Errors found: {errorCount} / {en_us_entries}{Color_Off}\n\n")
|
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate total english entries
|
||||||
|
total_en_us_entries = 0
|
||||||
|
for entries in en_us_entries.values():
|
||||||
|
total_en_us_entries += entries
|
||||||
|
|
||||||
# Write git Workflow summary
|
# Write git Workflow summary
|
||||||
gitWorkflowSummary = "### Translation progress\n| Language | Completion | Missing entries |\n|---|---|---|\n"
|
gitWorkflowSummary = "### Translation progress\n| Language | Completion (AB+) |Completion (REP) |Completion (REP+) |Completion (Total) |\n|---|---|---|---|---|\n"
|
||||||
print(f"{Blue}Translation progress:{Color_Off}")
|
print(f"{Blue}Translation progress:{Color_Off}")
|
||||||
for lang in languages:
|
for lang in languageProgress.keys():
|
||||||
print(
|
gitWorkflowSummary += f"| {lang} "
|
||||||
f"\t{BWhite}{lang}{Color_Off}\t{Blue}{round(languages[lang][0],2)}%{Color_Off}\t{Red}{languages[lang][1]} missing{Color_Off}"
|
totalMissing = 0
|
||||||
)
|
for dlc in dlcs:
|
||||||
errorMessage = languages[lang][1] if languages[lang][1] >3 else "🎉"
|
gitCompletionMessage = ""
|
||||||
gitWorkflowSummary += f"| {lang} | {round(languages[lang][0],2)}% | {errorMessage} |\n"
|
if dlc in languageProgress[lang]:
|
||||||
|
percent = round(languageProgress[lang][dlc][0], 2)
|
||||||
|
missingEntries = languageProgress[lang][dlc][1]
|
||||||
|
totalMissing += missingEntries
|
||||||
|
print(f"\t{BWhite}{lang}({dlc}){Color_Off}\t{Blue}{percent}%{Color_Off}\t{Red}{missingEntries} missing{Color_Off}")
|
||||||
|
gitCompletionMessage = f"{percent}% ({missingEntries} left)" if missingEntries >3 else "100% 🎉"
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
f"\t{BWhite}{lang}({dlc}){Color_Off}\t\t{Red}DLC translation missing!{Color_Off}")
|
||||||
|
gitCompletionMessage = f"0% ({en_us_entries[dlc]} left)"
|
||||||
|
totalMissing += en_us_entries[dlc]
|
||||||
|
|
||||||
|
gitWorkflowSummary += f"| {gitCompletionMessage} "
|
||||||
|
|
||||||
|
totalPercent = round((total_en_us_entries - totalMissing) / total_en_us_entries * 100, 2)
|
||||||
|
gitWorkflowSummary += f"|{totalPercent}% ({totalMissing}) "
|
||||||
|
gitWorkflowSummary += "|\n"
|
||||||
|
|
||||||
|
print(gitWorkflowSummary)
|
||||||
|
|
||||||
if "GITHUB_STEP_SUMMARY" in os.environ:
|
if "GITHUB_STEP_SUMMARY" in os.environ:
|
||||||
print("\n\nwrite workflow summary to: ", os.environ["GITHUB_STEP_SUMMARY"])
|
print("\n\nwrite workflow summary to: ", os.environ["GITHUB_STEP_SUMMARY"])
|
||||||
|
|||||||
Reference in new issue
Block a user