-
Notifications
You must be signed in to change notification settings - Fork 0
/
AshenOrder_Repack.py
198 lines (169 loc) · 5.96 KB
/
AshenOrder_Repack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import os
import re
import sys
import pandas as pd
from config import config
####################################################################################################
# Override default parameter definitions for the Ashen Order repack
####################################################################################################
config.SPECIFIC_MPQ_FILE = 'Patch-Y.mpq'
# For extra custom content localization
config.REF_BUILD = '11.0.2.55522'
# Dictionary for csv value matching
config.CSV_VALUE_MATCHING_DICT = {
'Spell.csv': ['Spell.csv', 'SpellName.csv']
}
# Dictionary for string searching
config.STRING_SEARCHING_DICT = {
'GlobalStrings.lua': {
'GlobalStrings.csv': 'TagText_lang',
'ChrClasses.csv': 'Name_lang',
'ChrRaces.csv': 'Name_lang',
'Creature.csv': 'Name_lang',
'ChrCustomizationReq.csv': 'ReqSource_lang',
'UiMapGroupMember.csv': 'Name_lang'
},
'ChrRaces.csv': {
'ChrClasses.csv': 'Name_lang',
'ChrRaces.csv': 'Name_lang',
'Creature.csv': 'Name_lang',
'ChrCustomizationReq.csv': 'ReqSource_lang'
}
}
####################################################################################################
from client_localization import (
run_export_dbc,
run_export_csv,
clean_csv_files,
update_localized_csv,
import_csv_to_dbc,
add_files_to_mpq
)
from utils import (
find_and_remove_duplicate_definitions,
compare_and_generate_diff,
update_lua_file_in_place,
find_value_in_csv
)
repack_data_dir = './Data/AshenOrder_Repack/V1'
build = config.BUILD
t_lang = config.T_LANG
csv_dir = config.CSV_DIR
string_searching_dict = config.STRING_SEARCHING_DICT
global_strings_files = [
'Interface/FrameXML/GlobalStrings.lua',
'Interface/GlueXML/GlueStrings.lua'
]
locales = [
'deDE',
'esES',
'esMX',
'frFR',
'koKR',
'ruRU',
'zhCN',
'zhTW'
]
def run_AshenOrder_localization():
repack_spec_files_dirs =[
f'{repack_data_dir}/common',
f'{repack_data_dir}/{t_lang}'
]
repack_spec_files = {
f'{repack_data_dir}/common': [
'Interface/GlueXML/GlueXML.toc',
'Interface/GlueXML/Config_de_Parche.lua',
'Interface/GlueXML/CharacterCreate.lua',
'Interface/GlueXML/CharacterSelect.lua',
'Interface/GlueXML/AccountLogin.xml',
'Interface/GlueXML/CharacterSelect.xml'
],
f'{repack_data_dir}/{t_lang}': global_strings_files + [
#''
]
}
mapping_global_strings()
update_global_strings()
update_localized_csv()
fix_race_name()
import_csv_to_dbc()
add_files_to_mpq(repack_spec_files_dirs, repack_spec_files)
print('Client localization complete!!!')
def run_AshenOrder_extraction(default=True):
run_export_dbc(default)
run_export_csv(default)
clean_csv_files(default=default)
def mapping_global_strings(locale=None):
lang = locale if locale else t_lang
for file in global_strings_files:
c_lang_retail = f'./Data/Retail/{build}/enUS/{file}'
c_lang_repack = f'{repack_data_dir}/enUS/{file}'
t_lang_retail = f'./Data/Retail/{build}/{lang}/{file}'
t_lang_repack = f'{repack_data_dir}/{lang}/{file}'
diff_json = f'{repack_data_dir}/{lang}/{file.replace('.lua', '_diff.json')}'
compare_and_generate_diff(
c_lang_retail,
c_lang_repack,
t_lang_retail,
t_lang_repack,
diff_json,
lang
)
def update_global_strings(locale=None):
lang = locale if locale else t_lang
for file in global_strings_files:
t_lang_repack = f'{repack_data_dir}/{lang}/{file}'
diff_json = f'{repack_data_dir}/{lang}/{file.replace('.lua', '_diff.json')}'
update_lua_file_in_place(t_lang_repack, diff_json, lang)
def check_global_strings_files():
for file in global_strings_files:
find_and_remove_duplicate_definitions(f'{repack_data_dir}/enUS/{file}')
def fix_race_name():
# Fix race names for localization
race_name_mapping = {
"High Elf": "High Elf",
"Pandaren|cffc41f3b|r": "Pandaren",
"Man'ari Eredar": "Man'ari Eredar",
"Lightforged": "Lightforged Draenei",
"Demon Hunter|cff0070de|r": "Demon Hunter",
"Demon Hunter|cffc41f3b|r": "Demon Hunter"
}
file = os.path.join(csv_dir['c_lang_localized'], 'ChrRaces.csv')
df = pd.read_csv(file, low_memory=False)
column = 'Name_Lang_enUS'
for key, value in race_name_mapping.items():
current_value = key
search_value = value
match_value = find_value_in_csv('ChrRaces.csv', string_searching_dict, search_value)
target_value = replace_extracted_text(current_value, match_value)
df.loc[df[column] == current_value, column] = target_value
df.to_csv(file, index=False)
def replace_extracted_text(input_string, replacement):
match = re.match(r'([^|]*)', input_string)
if match:
extracted_text = match.group(1)
else:
extracted_text = input_string
replaced_string = input_string.replace(extracted_text, replacement, 1)
return replaced_string
def run_mapping_global_strings():
for locale in locales:
mapping_global_strings(locale)
def run_update_global_strings():
for locale in locales:
update_global_strings(locale)
alias_to_function = {
'check': check_global_strings_files,
'mapping': run_mapping_global_strings,
'update': run_update_global_strings
}
if __name__ == "__main__":
if len(sys.argv) > 1:
alias = sys.argv[1]
func = alias_to_function.get(alias)
if func:
func()
else:
print(f"Alias '{alias}' not found.")
else:
print("Please provide an alias as an argument.")