added basic nametranslations for global languages
This commit is contained in:
parent
057273552b
commit
9b998704e2
1 changed files with 30 additions and 12 deletions
|
|
@ -10,13 +10,24 @@ from multiprocessing import Pool
|
||||||
|
|
||||||
|
|
||||||
def update_names(dir_in, old_path, languages, is_global):
|
def update_names(dir_in, old_path, languages, is_global):
|
||||||
names = extract_names(dir_in)
|
names = extract_names(dir_in, is_global)
|
||||||
|
|
||||||
|
global_languages = {"enm": 1, "zh": 2, "ko": 3}
|
||||||
|
if is_global:
|
||||||
|
languages = global_languages.keys()
|
||||||
|
|
||||||
# we have to update japanese like the rest because CustomData exists
|
# we have to update japanese like the rest because CustomData exists
|
||||||
# and POKELABO deleted the wedding gear event stuff from the game files
|
# and POKELABO deleted the wedding gear event stuff from the game files
|
||||||
for l in languages:
|
for l in languages:
|
||||||
if l == "jpn":
|
if l == "jpn":
|
||||||
out_dict = dict(zip(names, names))
|
out_dict = dict(zip(names, names))
|
||||||
|
elif l in global_languages.keys():
|
||||||
|
out_dict = {}
|
||||||
|
for name in names:
|
||||||
|
spl = name.split("\t")
|
||||||
|
idx = global_languages[l]
|
||||||
|
val = spl[idx] if spl[idx] != "None" else ""
|
||||||
|
out_dict[spl[0]] = val
|
||||||
else:
|
else:
|
||||||
out_dict = dict.fromkeys(names, "")
|
out_dict = dict.fromkeys(names, "")
|
||||||
|
|
||||||
|
|
@ -34,13 +45,13 @@ def update_names(dir_in, old_path, languages, is_global):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def extract_names(dir_in):
|
def extract_names(dir_in, is_global):
|
||||||
char_tsv_path = os.path.join(dir_in, "Diva", "Settings", "Character.tsv")
|
char_tsv_path = os.path.join(dir_in, "Diva", "Settings", "Character.tsv")
|
||||||
|
|
||||||
if not os.path.isfile(char_tsv_path):
|
if not os.path.isfile(char_tsv_path):
|
||||||
raise FileNotFoundError("Character.tsv not found")
|
raise FileNotFoundError("Character.tsv not found")
|
||||||
|
|
||||||
names, sets = read_char_tsv(char_tsv_path)
|
names, sets = read_char_tsv(char_tsv_path, is_global)
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
f
|
f
|
||||||
|
|
@ -50,18 +61,20 @@ def extract_names(dir_in):
|
||||||
if len(files) == 0:
|
if len(files) == 0:
|
||||||
raise FileNotFoundError("No valid files found in directory: " + dir_in)
|
raise FileNotFoundError("No valid files found in directory: " + dir_in)
|
||||||
|
|
||||||
# tfw gil
|
# TODO unsupported on global for now
|
||||||
# it's still faster on my machine so i'm keeping it
|
if not is_global:
|
||||||
read_partial = partial(read_mission, char_names=names, char_sets=sets)
|
# tfw gil
|
||||||
with Pool() as p:
|
# it's still faster on my machine so i'm keeping it
|
||||||
new_names = p.map(read_partial, files)
|
read_partial = partial(read_mission, char_names=names, char_sets=sets)
|
||||||
for x in new_names:
|
with Pool() as p:
|
||||||
names.update(x)
|
new_names = p.map(read_partial, files)
|
||||||
|
for x in new_names:
|
||||||
|
names.update(x)
|
||||||
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
def read_char_tsv(char_tsv_path):
|
def read_char_tsv(char_tsv_path, is_global):
|
||||||
char_names = set()
|
char_names = set()
|
||||||
char_sets = set()
|
char_sets = set()
|
||||||
|
|
||||||
|
|
@ -77,7 +90,12 @@ def read_char_tsv(char_tsv_path):
|
||||||
and row["CharacterName"].strip()
|
and row["CharacterName"].strip()
|
||||||
and row["NameText"].strip()
|
and row["NameText"].strip()
|
||||||
):
|
):
|
||||||
char_names.add(row["NameText"])
|
if is_global:
|
||||||
|
char_names.add(
|
||||||
|
f"{row['NameText']}\t{row['CharaEnglish']}\t{row['CharaChinese']}\t{row['CharaKorean']}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
char_names.add(row["NameText"])
|
||||||
char_sets.add(row["CharacterName"])
|
char_sets.add(row["CharacterName"])
|
||||||
|
|
||||||
return char_names, char_sets
|
return char_names, char_sets
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue