diff --git a/compare_tools/compare_configs.py b/compare_tools/compare_configs.py index 9242f5b..2c1c16f 100644 --- a/compare_tools/compare_configs.py +++ b/compare_tools/compare_configs.py @@ -24,7 +24,6 @@ def compare_configs(cfg_previous: str, cfg_new: str): elif type(cfg_new) is Mod: cfg_new = cfg_new.download_locale_en(store=False) cfg_new = parse_config(cfg_new, is_file=False) - print(cfg_new) # Find sections or keys that have changed, were added, or removed diff --git a/compare_tools/format_output.py b/compare_tools/format_output.py index 69c5d2e..3e5cf57 100644 --- a/compare_tools/format_output.py +++ b/compare_tools/format_output.py @@ -12,9 +12,11 @@ } -def format_output(config_json, mod): +def format_output(config_json, mod, language): config_out = ConfigParser() config_ret = ConfigParser() + config_lang = ConfigParser() + config_lang.read(mod.path / f"locale/{language}/locale.cfg") added_sections = config_json["added_sections"] removed_sections = config_json["removed_sections"] @@ -24,7 +26,7 @@ def format_output(config_json, mod): path = "output/" + mod.name + "/locale.cfg" if not os.path.exists("output/" + mod.name): os.makedirs("output/" + mod.name) - + with open(path, "w+") as f: # added_sections for sections in "added_sections", "removed_sections": @@ -35,8 +37,11 @@ def format_output(config_json, mod): config_ret.add_section(section_name) for key, value in section.items(): - config_out.set(section_name, key, value) - config_ret.set(section_name, key, value) + config_out.set(section_name, key, + config_lang[section_name][kk]) + config_ret.set(section_name, key, + config_lang[section_name][kk]) + config_out.write(f) config_out = ConfigParser() f.write("#######################################\n") @@ -59,8 +64,10 @@ def format_output(config_json, mod): if sub_key == "modified_keys": # it is written as "from", "to" keys vv = vv["to"] - config_out.set(section_name, kk, vv) - config_ret.set(section_name, kk, vv) + config_out.set(section_name, kk, + config_lang[section_name][kk]) + config_ret.set(section_name, kk, + config_lang[section_name][kk]) config_out.write(f) config_out = ConfigParser() @@ -76,7 +83,6 @@ def format_output(config_json, mod): mod = Mod(args.mod_url) path_previous = mod.path_en / "locale.cfg" path_new = mod.path / "locale/fr/locale.cfg" - # path_new = mod.download_locale_en() diff = compare_configs(path_previous, path_new) format_output(diff, mod) diff --git a/compare_tools/init_mod_translation.py b/compare_tools/init_mod_translation.py index c349fd8..0c0dc01 100644 --- a/compare_tools/init_mod_translation.py +++ b/compare_tools/init_mod_translation.py @@ -3,16 +3,17 @@ from Mod import Mod + def init_mod(mod_repo_url, overwrite=False): mod = Mod(mod_repo_url) if os.path.exists(mod.path) and not overwrite: - raise FileExistsError("Mod folder already exists in repository. Use --f to overwrite.") + raise FileExistsError( + "Mod folder already exists in repository. Use --f to overwrite.") os.makedirs(mod.path_en, exist_ok=overwrite) mod.download_locale_en() - - print(f"Locale File downloaded for {mod.name} by {mod.owner}. Ready to translate!") - + print( + f"Locale File downloaded for {mod.name} by {mod.owner}. Ready to translate!") return mod diff --git a/mod_translate_track.py b/mod_translate_track.py index 01943ed..7a69c7c 100644 --- a/mod_translate_track.py +++ b/mod_translate_track.py @@ -19,8 +19,7 @@ def main(url: str, language: str): mod = Mod.Mod(url) diff = compare_configs.compare_configs( mod.path_en/"locale.cfg", mod) - # TODO: I am using local EN vs Language. I need to use remote EN vs locale EN AND output it in LANGUAGE - format_output.format_output(diff, mod) + format_output.format_output(diff, mod, language) if __name__ == "__main__":