mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-12-28 02:16:03 +00:00
add localizer script (https://github.com/HamletDuFromage/aio-switch-updater/issues/148)
This commit is contained in:
parent
2bcd784991
commit
b426a9fe5c
6 changed files with 90 additions and 184 deletions
|
@ -98,6 +98,10 @@ $ make
|
|||
|
||||
</details>
|
||||
|
||||
## Contribute
|
||||
|
||||
PRs and suggestions are encouraged! If you wish to help with the localization of the app, you can translate the files in `resources/i18n/`. To easily find the non-translated strings and translate them, you may use `localizer.py` (e.g. `python localizer.py -r resources//i18n//en-US//menus.json -w resources//i18n//fr//menus.json`).
|
||||
|
||||
## Disclaimer
|
||||
I do not own, host nor distribute any of the files that can be downloaded with this homebrew tool. At the owner's request, I will immediately remove the ability to download any problematic file.
|
||||
|
||||
|
|
78
localizer.py
Executable file
78
localizer.py
Executable file
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import argparse
|
||||
|
||||
|
||||
class Colors:
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKCYAN = '\033[96m'
|
||||
OKGREEN = '\033[92m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
|
||||
def color_string(self, message):
|
||||
return f"{self.OKCYAN}{message}{self.ENDC}"
|
||||
|
||||
|
||||
class Localizer:
|
||||
def __init__(self, reference_path, working_path):
|
||||
self.reference_dict = dict()
|
||||
self.working_dict = dict()
|
||||
self.out_dict = dict()
|
||||
self.reference_path = reference_path
|
||||
self.working_path = working_path
|
||||
self.init_dicts()
|
||||
|
||||
def init_dicts(self):
|
||||
with open(self.reference_path) as reference_file:
|
||||
self.reference_dict = json.load(reference_file)
|
||||
with open(self.working_path) as working_file:
|
||||
self.working_dict = json.load(working_file)
|
||||
|
||||
def get_new_dict(self):
|
||||
self.out_dict = self.update_values(self.reference_dict, self.working_dict)[0]
|
||||
|
||||
def update_values(self, reference_dict, working_dict):
|
||||
colors = Colors()
|
||||
done = False
|
||||
for key, value in reference_dict.items():
|
||||
if done:
|
||||
return (working_dict, True)
|
||||
if isinstance(value, dict):
|
||||
if key not in working_dict:
|
||||
working_dict[key] = dict()
|
||||
working_dict[key], done = self.update_values(
|
||||
value, working_dict[key])
|
||||
elif key not in working_dict:
|
||||
working_val = input(
|
||||
f"Translation for key: [{key}] was not found.\nType in the translation in the field below.\nType \"_exit\" to save & quit and \"_skip\" to go to skip to the next key.\n<<< {colors.color_string(repr(value)[1:-1])}\n>>> ")
|
||||
if working_val == "_exit":
|
||||
return (working_dict, True)
|
||||
elif working_val == "_skip":
|
||||
continue
|
||||
working_dict[key] = working_val
|
||||
return (working_dict, False)
|
||||
|
||||
def update_file(self):
|
||||
self.get_new_dict()
|
||||
with open(self.working_path, 'w') as working_file:
|
||||
json.dump(self.out_dict, working_file, indent=2, ensure_ascii=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Compare and update JSON translation files")
|
||||
required = parser.add_argument_group('Required arguments')
|
||||
required.add_argument('-r', '--reference',
|
||||
help='reference file', required=True)
|
||||
required.add_argument(
|
||||
'-w', '--working', help='working file, will be edited', required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
loc = Localizer(args.reference, args.working)
|
||||
loc.update_file()
|
|
@ -15,7 +15,7 @@
|
|||
"view": "View installed cheats",
|
||||
"exclude": "Exclude games from receiving cheat updates",
|
||||
"delete_existing": "Delete all existing cheat codes",
|
||||
"delete_orphaned": "Delete orphaned cheat chodes",
|
||||
"delete_orphaned": "Delete orphaned cheat codes",
|
||||
"deleting": "Deleting…",
|
||||
"cheastlips_title": "Cheatslips cheats",
|
||||
"gbatemp_title": "GBAtemp cheats",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"about": {
|
||||
"title": "All-in-One Nintendo Switch Updater",
|
||||
"copyright": "AIO-switch-updater est distribuée sous la license GPL-3.0\n© 2020-2021 HamletDuFromage",
|
||||
"disclaimers": "\ue016 À part les cheat codes qui proviennent d'un mirroir d'un topic Gbatemp, HamletDuFromage n'héberge rien. Tous les crédits vont aux propriétaires respectifs.\n\ue016 Les liens sont actualisés toutes les 3 heures. Si un lien reste inactif après 3 heures, merci de bien vouloir ouvrir une issue sur GitHub.\n"
|
||||
"disclaimers": " À part les cheat codes qui proviennent d'un mirroir d'un topic Gbatemp, HamletDuFromage n'héberge rien. Tous les crédits vont aux propriétaires respectifs.\n Les liens sont actualisés toutes les 3 heures. Si un lien reste inactif après 3 heures, merci de bien vouloir ouvrir une issue sur GitHub.\n"
|
||||
},
|
||||
"cheats": {
|
||||
"installed": "Codes de triche installés",
|
||||
|
@ -18,7 +18,8 @@
|
|||
"deleting": "Suppression en cours",
|
||||
"exclude_titles": "Exclure des titres",
|
||||
"exclude_titles_desc": "Vous pouvez desactiver les mises à jour de codes dans ce menu",
|
||||
"exclude_titles_save": "Sauvegarde et retour"
|
||||
"exclude_titles_save": "Sauvegarde et retour",
|
||||
"delete_orphaned": "Supprimer les codes de triche orphelins"
|
||||
},
|
||||
"common": {
|
||||
"downloading": "Téléchargement en cours…",
|
||||
|
@ -61,16 +62,16 @@
|
|||
},
|
||||
"main": {
|
||||
"getting": "Téléchargement de {}",
|
||||
"firmware_text": "\ue016 Firmware depuis 'https://darthsternie.net/switch-firmwares/'. Une fois téléchargés, ils seront dans '/firmware'. Vous pouvez ensuite les installer avec Daybreak.\n\ue016 FW actuel : ",
|
||||
"cheats_text": "\ue016 Archive mise à jour quotidiennement des codes de triche de 'gbatemp.net'. Les codes de triche pour les jeux que vous ne possedez pas ne seront pas extraits sur votre carte SD. Vous pouvez désactiver les mises à jour pour pour une sélection de jeux dans le menu 'Outils->Menu de cheat'.\n\ue016 Version actuelle des cheats : ",
|
||||
"firmware_text": " Firmware depuis 'https://darthsternie.net/switch-firmwares/'. Une fois téléchargés, ils seront dans '/firmware'. Vous pouvez ensuite les installer avec Daybreak.\n FW actuel : ",
|
||||
"cheats_text": " Archive mise à jour quotidiennement des codes de triche de 'gbatemp.net'. Les codes de triche pour les jeux que vous ne possedez pas ne seront pas extraits sur votre carte SD. Vous pouvez désactiver les mises à jour pour pour une sélection de jeux dans le menu 'Outils->Menu de cheat'.\n Version actuelle des cheats : ",
|
||||
"sigpatches": "sigpatches",
|
||||
"sigpatches_text": "\ue016 Les Sigpatches permettent à votre Switch d'installer et d'exécuter des fichiers NSP non officiels. Assurez-vous de choisir les bons patchs pour votre configuration (Atmosphère seul ou Hekate + Atmosphère).",
|
||||
"sigpatches_text": " Les Sigpatches permettent à votre Switch d'installer et d'exécuter des fichiers NSP non officiels. Assurez-vous de choisir les bons patchs pour votre configuration (Atmosphère seul ou Hekate + Atmosphère).",
|
||||
"firmware": "firmware",
|
||||
"not_found": "non trouvé",
|
||||
"latest_cheats": "Dernière version",
|
||||
"app": "app",
|
||||
"cfw": "CFW",
|
||||
"cfw_text": "\ue016 Principaux CFWs. Si vous souhaitez utiliser Atmosphère avec Hekate, téléchargez Atmosphère, puis Hekate.",
|
||||
"cfw_text": " Principaux CFWs. Si vous souhaitez utiliser Atmosphère avec Hekate, téléchargez Atmosphère, puis Hekate.",
|
||||
"cheats": "codes de triche",
|
||||
"links_not_found": "Impossible de trouver un lien de téléchargement, assurez-vous que la Switch soit connectée à internet.\nSi ce problème persiste, veuillez ouvrir une issue sur GitHub.",
|
||||
"new_update": " - Nouvelle MÀJ de l'app disponible",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,176 +0,0 @@
|
|||
import json
|
||||
|
||||
lookupTable = {
|
||||
"About_Title" : ["about", "title"],
|
||||
"copyright" : ["about", "copyright"],
|
||||
"Disclaimers" : ["about", "disclaimers"],
|
||||
"donate" : ["about", "donate"],
|
||||
"app_title" : ["cheats", "installed"],
|
||||
"app_label" : ["cheats", "label"],
|
||||
"text_download" : ["cheats", "downloading"],
|
||||
"text_download_list" : ["cheats", "dl_latest"],
|
||||
"text_title": ["cheats", "getting_cheats"],
|
||||
"Downloading" : ["common", "downloading"],
|
||||
"tool_extracting" : ["common", "extracting"],
|
||||
"Extracting" : ["common", "extracting"],
|
||||
"All_done" : ["common", "all_done"],
|
||||
"Changelog" : ["changelog", "changelog"],
|
||||
"cheat_menu" : ["cheats", "menu"],
|
||||
"cheat_view" : ["cheats", "view"],
|
||||
"cheat_exclude" : ["cheats", "exclude"],
|
||||
"cheat_delete_all_ex" : ["cheats", "delete_existing"],
|
||||
"cheat_delete_all_cheat" : ["cheats", "delete_all"],
|
||||
"cheat_Deleting" : ["cheats", "deleting"],
|
||||
"cheat_All_done" : ["common", "all_done"],
|
||||
"please_reboot" : ["sigpatches", "reboot"],
|
||||
"cheastlips_title" : ["cheats", "cheastlips_title"],
|
||||
"get_cheatslips" : ["cheats", "get_cheatslips"],
|
||||
"cheatslips_label" : ["cheats", "cheatslips_label"],
|
||||
"download_cheatslips" : ["cheats", "cheatslips_dl"],
|
||||
"delete_cheat" : ["cheats", "delete_file"],
|
||||
"couldnt_dl_cheats" : ["cheats", "cheatslips_error"],
|
||||
"quota_cheatslips" : ["cheats", "quota"],
|
||||
"cheat_cheat_content" : ["cheats", "sheet_content"],
|
||||
"app_cheatslips_label" : ["cheats", "cheatslips_select"],
|
||||
"wrong_cheatslips_id" : ["cheats", "cheatslips_wrong_id"],
|
||||
"keyboard_no_show" : ["cheats", "kb_error"],
|
||||
"see_more" : ["cheats", "cheatslips_see_more"],
|
||||
"download_cheats" : ["cheats", "cheatslips_dl_cheats"],
|
||||
"bid_not_found" : ["cheats", "bid_not_found"],
|
||||
"choice_yes": ["common", "Yes"],
|
||||
"choice_no": ["common", "No"],
|
||||
"Back" : ["common", "back"],
|
||||
"Continue" : ["common", "continue"],
|
||||
"Download_payloads" : ["payloads", "dl_payloads"],
|
||||
"select" : ["payloads", "select"],
|
||||
"Download" : ["common", "download"],
|
||||
"from" : ["common", "from"],
|
||||
"down" : ["common", "downloading"],
|
||||
"download_all_done" : ["common", "all_done"],
|
||||
"description" : ["payloads", "not_found"],
|
||||
"back" : ["common", "back"],
|
||||
"exclude_titles" : ["cheats", "exclude_titles"],
|
||||
"you_can" : ["cheats", "exclude_titles_desc"],
|
||||
"save" : ["cheats", "exclude_titles_save"],
|
||||
"joy_con" : ["joy_con", "title"],
|
||||
"jc_you_can_1" : ["joy_con", "desc_1"],
|
||||
"jc_you_can_goto" : ["joy_con", "desc_2"],
|
||||
"jc_you_can_2" : ["joy_con", "desc_3"],
|
||||
"jc_backup" : ["joy_con", "backup"],
|
||||
"jc_color" : ["joy_con", "label"],
|
||||
"jc_backing" : ["joy_con", "backing_up"],
|
||||
"jc_all_done" : ["common", "all_done"],
|
||||
"jc_change" : ["joy_con", "changing"],
|
||||
"jc_all_" : ["joy_con", "all_done"],
|
||||
"pro_con" : ["pro_con", "title"],
|
||||
"pc_you_can" : ["pro_con", "desc"],
|
||||
"pc_color" : ["pro_con", "label"],
|
||||
"pc_backing" : ["pro_con", "backing_up"],
|
||||
"pc_all_done" : ["pro_con", "all_done"],
|
||||
"Getting" : ["main", "getting"],
|
||||
"firmware_text" : ["main", "firmware_text"],
|
||||
"currentCeatsver" : ["main", "cheats_text"],
|
||||
"operation_1" : ["main", "sigpatches"],
|
||||
"list_sigpatches" : ["main", "sigpatches_text"],
|
||||
"operation_2" : ["main", "firmware"],
|
||||
"list_not" : ["main", "not_found"],
|
||||
"list_latest" : ["main", "latest_cheats"],
|
||||
"list_app" : ["main", "app"],
|
||||
"list_cfw" : ["main", "cfw"],
|
||||
"list_ams": ["main", "ams_text"],
|
||||
"list_main" : ["main", "cfw_text"],
|
||||
"list_latest_ver" : ["main", "cheats_text"],
|
||||
"list_cheats" : ["main", "cheats"],
|
||||
"list_down" : ["common", "download"],
|
||||
"list_from" : ["common", "from"],
|
||||
"list_downing" : ["common", "downloading"],
|
||||
"list_extracting" : ["common", "extracting"],
|
||||
"list_All" : ["common", "all_done"],
|
||||
"list_could_done" : ["main", "links_not_found"],
|
||||
"main_app" : ["main", "new_update"],
|
||||
"main_about" : ["main", "about"],
|
||||
"main_update_ams" : ["main", "update_ams"],
|
||||
"main_update_cfw" : ["main", "update_cfw"],
|
||||
"main_update_si" : ["main", "update_sigpatches"],
|
||||
"main_firmwares" : ["main", "download_firmware"],
|
||||
"main_cheats" : ["main", "download_cheats"],
|
||||
"main_tools" : ["main", "tools"],
|
||||
"payload_reboot" : ["payloads", "reboot_title"],
|
||||
"payload_select" : ["payloads", "select"],
|
||||
"payload_set" : ["payloads", "set_reboot_payload"],
|
||||
"payload_set_up" : ["payloads", "set_update_bin"],
|
||||
"payload_success" : ["payloads", "copy_success"],
|
||||
"payload_to" : ["payloads", "to"],
|
||||
"payload_ok" : ["common", "ok"],
|
||||
"payload_shut" : ["common", "shut_down"],
|
||||
"payload_reboot_2" : ["common", "reboot"],
|
||||
"hide_tabs_page" : ["hide", "title"],
|
||||
"hide_tabs_label" : ["hide", "desc"],
|
||||
"tool_cheats" : ["tools", "cheats"],
|
||||
"tool_change" : ["tools", "joy_cons"],
|
||||
"tool_change_procon" : ["tools", "pro_cons"],
|
||||
"tool_download" : ["tools", "dl_payloads"],
|
||||
"tool_inject" : ["tools", "inject_payloads"],
|
||||
"tool_update" : ["tools", "update_app"],
|
||||
"tool_DownLoad" : ["tools", "dl_app"],
|
||||
"tool_updating" : ["common", "updating"],
|
||||
"tool_downloading" : ["common", "downloading"],
|
||||
"tool_all_done" : ["common", "all_done"],
|
||||
"tool_changelog" : ["tools", "changelog"],
|
||||
"tool_cleanUp" : ["tools", "clean_up"],
|
||||
"hide_tabs" : ["tools", "hide_tabs"],
|
||||
"tool_net_settings" : ["tools", "internet_settings"],
|
||||
"tool_browser" : ["tools", "browser"],
|
||||
"utils_because" : ["utils", "fw_warning"],
|
||||
"utils_ok" : ["common", "ok"],
|
||||
"utils_do" : ["utils", "overwrite"],
|
||||
"utils_no" : ["common", "no"],
|
||||
"utils_yes" : ["common", "yes"],
|
||||
"utils_the" : ["utils", "wrong_type_sigpatches"],
|
||||
"utils_the_downloaded" : ["utils", "wrong_type_fw"],
|
||||
"ultils_overwrite" : ["utils", "overwrite_inis"],
|
||||
"ultis_file" : ["utils", "wrong_type_cfw"],
|
||||
"reboot_rcm" : ["ams_update", "reboot_rcm"],
|
||||
"hekate_dialogue" : ["ams_update", "install_hekate"],
|
||||
"Yes" : ["common", "yes"],
|
||||
"No" : ["common", "no"],
|
||||
"net_settings" : ["net", "title"],
|
||||
"go_back" : ["common", "go_back"],
|
||||
"Confirm_button" : ["common", "confirm"],
|
||||
"Cancel_button" : ["common", "cancel"],
|
||||
"tool_copyFiles" : ["tools", "batch_copy"],
|
||||
"files_not_found" : ["tools", "batch_copy_not_found"],
|
||||
"copy_files_not_found" : ["tools", "batch_copy_config_not_found"],
|
||||
"delete_contents" : ["ams_update", "delete_contents"],
|
||||
"launch_warning" : ["main", "launch_warning"]
|
||||
}
|
||||
|
||||
lookupTableSmol = {
|
||||
"About_Title" : ["about", "title"],
|
||||
"copyright" : ["about", "copyright"],
|
||||
"Disclaimers" : ["about", "disclaimer"]
|
||||
}
|
||||
|
||||
with open('menus.json') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
def populate(data, t):
|
||||
res = {}
|
||||
for e in t:
|
||||
if(e in data):
|
||||
if(t[e][0] not in res):
|
||||
res[t[e][0]] = {}
|
||||
res[t[e][0]][t[e][1]] = data[e]
|
||||
return res
|
||||
|
||||
def sed_command(t):
|
||||
command = "'"
|
||||
for e in t:
|
||||
command += "s#" + "menus/" + e + "#" + "menus/" + t[e][0] + "/" + t[e][1] + "#g;"
|
||||
command += command[:-1] + "'"
|
||||
return command
|
||||
|
||||
with open("menus.json", "w") as outfile:
|
||||
json.dump(populate(data, lookupTable), outfile, ensure_ascii=False, indent=2)
|
||||
|
||||
print(sed_command(lookupTable))
|
Loading…
Reference in a new issue