47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
|
import json
|
||
|
from deep_translator import GoogleTranslator
|
||
|
from helpers import capfirst
|
||
|
from encryption import encrypt_file
|
||
|
|
||
|
# ======================================================================================
|
||
|
destinationLanguage = "english"
|
||
|
destinationKey = "englishUsText"
|
||
|
|
||
|
wordlist = json.load(open(file="./Data_exported/Data_mods/x64/datatable/dec/wordlist.json", encoding="utf-8"))
|
||
|
doncos = json.load(open(file="./Data_decrypted/don_cos_reward.json", encoding="utf-8"))
|
||
|
# ======================================================================================
|
||
|
|
||
|
|
||
|
def fetchKey(key: str):
|
||
|
for wordentry in wordlist["items"]:
|
||
|
if wordentry["key"] == key:
|
||
|
return wordentry
|
||
|
|
||
|
|
||
|
translator = GoogleTranslator(source="japanese", target=destinationLanguage)
|
||
|
|
||
|
for costume in doncos["items"]:
|
||
|
cosType = costume["cosType"]
|
||
|
costumeId = costume["uniqueId"]
|
||
|
costumeNameKey = f"costume_{cosType}_{costumeId}"
|
||
|
key = fetchKey(key=costumeNameKey)
|
||
|
key[destinationKey] = capfirst(translator.translate(key["japaneseText"]))
|
||
|
|
||
|
print(
|
||
|
cosType,
|
||
|
(str(costumeId) + ":"),
|
||
|
key["japaneseText"],
|
||
|
"->",
|
||
|
key[destinationKey],
|
||
|
)
|
||
|
|
||
|
updatedWordList = json.dumps(wordlist, indent=4, ensure_ascii=False)
|
||
|
with open(
|
||
|
"./Data_exported/Data_mods/x64/datatable/dec/wordlist_costume_translated.json", "w", encoding="utf8"
|
||
|
) as outfile:
|
||
|
outfile.write(updatedWordList)
|
||
|
|
||
|
file = encrypt_file(input_file="./Data_exported/Data_mods/x64/datatable/dec/wordlist_costume_translated.json")
|
||
|
with open("./Data_exported/Data_mods/x64/datatable/wordlist_costume_translated.bin", "wb") as outfile:
|
||
|
outfile.write(file)
|