mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 18:58:27 +02:00
added translation system
added english language
This commit is contained in:
parent
9517e7716d
commit
117d62738c
7 changed files with 102 additions and 44 deletions
5
main.pyw
5
main.pyw
|
@ -10,11 +10,12 @@ import glob
|
|||
import os
|
||||
|
||||
from source.definition import *
|
||||
from source.check_update import *
|
||||
|
||||
class ClassApp():
|
||||
from source.__init__ import __init__
|
||||
from source.translate import translate
|
||||
from source.Progress import Progress
|
||||
from source.check_update import check_update
|
||||
from source.StateButton import StateButton
|
||||
from source.create_lecode_config import create_lecode_config
|
||||
from source.patch_file import patch_file
|
||||
|
@ -22,5 +23,7 @@ class ClassApp():
|
|||
|
||||
|
||||
# TODO: Langue
|
||||
# TODO: Wiki Github
|
||||
# TODO: Autogénération des bmg
|
||||
App = ClassApp()
|
||||
mainloop()
|
|
@ -6,25 +6,29 @@ import os
|
|||
|
||||
from .definition import *
|
||||
from .check_update import check_update
|
||||
from .translate import translate
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.language = "fr"
|
||||
|
||||
self.root = Tk()
|
||||
self.root.title("MKWFaraphel Installateur")
|
||||
self.root.title(self.translate("MKWFaraphel Installateur"))
|
||||
self.root.resizable(False, False)
|
||||
self.root.iconbitmap(bitmap="./icon.ico")
|
||||
|
||||
self.frame_game_path = LabelFrame(self.root, text="Jeu original")
|
||||
self.frame_game_path = LabelFrame(self.root, text=self.translate("Jeu original"))
|
||||
self.frame_game_path.grid(row=1, column=1)
|
||||
|
||||
check_update()
|
||||
self.check_update()
|
||||
self.path_mkwf = None
|
||||
|
||||
entry_game_path = Entry(self.frame_game_path, width=50)
|
||||
entry_game_path.grid(row=1, column=1, sticky="NEWS")
|
||||
|
||||
def select_path():
|
||||
path = filedialog.askopenfilename(filetypes=(("Jeu Wii", r"*.iso *.wbfs main.dol *.wia *.ciso"),))
|
||||
path = filedialog.askopenfilename(filetypes=((self.translate("Jeu Wii"),
|
||||
r"*.iso *.wbfs main.dol *.wia *.ciso"),))
|
||||
if os.path.exists(path):
|
||||
entry_game_path.delete(0, END)
|
||||
entry_game_path.insert(0, path)
|
||||
|
@ -36,13 +40,14 @@ def __init__(self):
|
|||
self.frame_action.grid_forget()
|
||||
path = entry_game_path.get()
|
||||
if not (os.path.exists(path)):
|
||||
messagebox.showerror("Erreur", "Le chemin de fichier est invalide")
|
||||
messagebox.showerror(self.translate("Erreur"), self.translate("Le chemin de fichier est invalide"))
|
||||
return
|
||||
|
||||
extension = get_extension(path)
|
||||
if extension.upper() == "DOL":
|
||||
if messagebox.askyesno("Attention", "Ce dossier sera écrasé si vous installer le mod !\n" + \
|
||||
"Êtes-vous sûr de vouloir l'utiliser ?"):
|
||||
if messagebox.askyesno(self.translate("Attention"),
|
||||
self.translate("Ce dossier sera écrasé si vous installer le mod !\n" +
|
||||
"Êtes-vous sûr de vouloir l'utiliser ?")):
|
||||
self.path_mkwf = os.path.realpath(path + "/../../")
|
||||
elif extension.upper() in ["ISO", "WBFS", "WIA", "CSIO"]:
|
||||
self.path_mkwf, i = os.path.realpath(path + "/../MKWiiFaraphel"), 1
|
||||
|
@ -51,19 +56,20 @@ def __init__(self):
|
|||
if not (os.path.exists(self.path_mkwf)): break
|
||||
self.path_mkwf, i = os.path.realpath(path + f"/../MKWiiFaraphel ({i})"), i + 1
|
||||
|
||||
self.Progress(show=True, indeter=True, statut="Extraction du jeu...")
|
||||
self.Progress(show=True, indeter=True, statut=self.translate("Extraction du jeu..."))
|
||||
subprocess.call(["./tools/wit/wit", "EXTRACT", path, "--DEST", self.path_mkwf]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
self.Progress(show=False)
|
||||
|
||||
else:
|
||||
messagebox.showerror("Erreur", "Le type de fichier n'est pas reconnu")
|
||||
messagebox.showerror(self.translate("Erreur"), self.translate("Le type de fichier n'est pas reconnu"))
|
||||
self.Progress(show=False)
|
||||
return
|
||||
|
||||
if os.path.exists(self.path_mkwf + "/files/rel/lecode-PAL.bin"):
|
||||
messagebox.showwarning("Attention", "Cette ROM est déjà moddé, " + \
|
||||
"il est déconseillé de l'utiliser pour installer le mod")
|
||||
messagebox.showwarning(self.translate("Attention"),
|
||||
self.translate("Cette ROM est déjà moddé, " +
|
||||
"il est déconseillé de l'utiliser pour installer le mod"))
|
||||
|
||||
self.frame_action.grid(row=2, column=1, sticky="NEWS")
|
||||
self.Progress(show=False)
|
||||
|
@ -72,18 +78,20 @@ def __init__(self):
|
|||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
self.button_game_extract = Button(self.frame_game_path, text="Extraire le fichier", relief=RIDGE, command=use_path)
|
||||
self.button_game_extract = Button(self.frame_game_path, text=self.translate("Extraire le fichier"),
|
||||
relief=RIDGE, command=use_path)
|
||||
self.button_game_extract.grid(row=2, column=1, columnspan=2, sticky="NEWS")
|
||||
|
||||
self.frame_action = LabelFrame(self.root, text="Action")
|
||||
self.frame_action = LabelFrame(self.root, text=self.translate("Action"))
|
||||
|
||||
self.button_prepare_file = Button(self.frame_action, text="Preparer les fichiers", relief=RIDGE,
|
||||
self.button_prepare_file = Button(self.frame_action, text=self.translate("Preparer les fichiers"), relief=RIDGE,
|
||||
command=self.patch_file, width=45)
|
||||
self.button_prepare_file.grid(row=1, column=1, columnspan=2, sticky="NEWS")
|
||||
self.button_install_mod = Button(self.frame_action, text="Installer le mod", relief=RIDGE, command=self.install_mod,
|
||||
width=35)
|
||||
self.listbox_outputformat = ttk.Combobox(self.frame_action, values=["Dossier", "ISO", "WBFS", "CISO"], width=5)
|
||||
self.listbox_outputformat.set("Dossier")
|
||||
self.button_install_mod = Button(self.frame_action, text=self.translate("Installer le mod"), relief=RIDGE,
|
||||
command=self.install_mod, width=35)
|
||||
self.listbox_outputformat = ttk.Combobox(self.frame_action, values=[self.translate("Dossier"),
|
||||
"ISO", "WBFS", "CISO"], width=5)
|
||||
self.listbox_outputformat.set(self.translate("Dossier"))
|
||||
# Le boutton d'installation du mod n'est affiché qu'après avoir préparer les fichiers
|
||||
|
||||
self.progressbar = ttk.Progressbar(self.root)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from tkinter import messagebox
|
||||
from . import *
|
||||
import requests
|
||||
import zipfile
|
||||
|
@ -7,30 +6,30 @@ import sys
|
|||
import os
|
||||
|
||||
VERSION_FILE_URL = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/version"
|
||||
def check_update():
|
||||
def check_update(self):
|
||||
try:
|
||||
gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
|
||||
with open("version", "rb") as f:
|
||||
locversion = json.load(f)
|
||||
|
||||
if gitversion["version"] != locversion["version"]:
|
||||
if messagebox.askyesno("Mise à jour disponible !", "Une mise à jour est disponible, souhaitez-vous l'installer ?\n\n"+ \
|
||||
f"Version : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
|
||||
if messagebox.askyesno(self.translate("Mise à jour disponible !"), self.translate("Une mise à jour est disponible, souhaitez-vous l'installer ?") +
|
||||
f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
|
||||
f"Changelog :\n{gitversion['changelog']}"):
|
||||
|
||||
if not(os.path.exists("./Updater/Updater.exe")):
|
||||
dl = requests.get(gitversion["updater_bin"], allow_redirects=True)
|
||||
with open("./download.zip", "wb") as file:
|
||||
print(f"Téléchargement de Updater en cours...")
|
||||
print(self.translate("Téléchargement de Updater en cours..."))
|
||||
file.write(dl.content)
|
||||
print("fin du téléchargement, début de l'extraction...")
|
||||
print(self.translate("fin du téléchargement, début de l'extraction..."))
|
||||
|
||||
with zipfile.ZipFile("./download.zip") as file:
|
||||
file.extractall("./Updater/")
|
||||
print("fin de l'extraction")
|
||||
print(self.translate("fin de l'extraction"))
|
||||
|
||||
os.remove("./download.zip")
|
||||
print("lancement de l'application...")
|
||||
print(self.translate("lancement de l'application..."))
|
||||
os.startfile(os.path.realpath("./Updater/Updater.exe"))
|
||||
sys.exit()
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ def install_mod(self):
|
|||
extracted_file = []
|
||||
max_step, step = 1, 0
|
||||
|
||||
def count_rf(path, file, subpath="/"):
|
||||
def count_rf(path):
|
||||
nonlocal max_step
|
||||
max_step += 1
|
||||
extension = get_extension(path)
|
||||
|
@ -30,20 +30,20 @@ def install_mod(self):
|
|||
for fp in fs:
|
||||
for f in glob.glob(self.path_mkwf + "/files/" + fp, recursive=True):
|
||||
if type(fs[fp]) == str:
|
||||
count_rf(path=f, file=fs[fp])
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp]) == dict:
|
||||
for nf in fs[fp]:
|
||||
if type(fs[fp][nf]) == str:
|
||||
count_rf(path=f, subpath=nf, file=fs[fp][nf])
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp][nf]) == list:
|
||||
for ffp in fs[fp][nf]: count_rf(path=f, subpath=nf, file=ffp)
|
||||
for ffp in fs[fp][nf]: count_rf(path=f)
|
||||
###
|
||||
extracted_file = []
|
||||
max_step += 4 # PATCH main.dol et PATCH lecode.bin, conversion, changement d'ID
|
||||
self.Progress(show=True, indeter=False, statut="Installation du mod", max=max_step, step=0)
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Installation du mod"), max=max_step, step=0)
|
||||
|
||||
def replace_file(path, file, subpath="/"):
|
||||
self.Progress(statut=f"Modification de\n{get_nodir(path)}", add=1)
|
||||
self.Progress(statut=self.translate("Modification de")+f"\n{get_nodir(path)}", add=1)
|
||||
# print(path, subpath, file)
|
||||
extension = get_extension(path)
|
||||
|
||||
|
@ -77,16 +77,16 @@ def install_mod(self):
|
|||
for ffp in fs[fp][nf]: replace_file(path=f, subpath=nf, file=ffp)
|
||||
|
||||
for file in extracted_file:
|
||||
self.Progress(statut=f"Recompilation de\n{get_nodir(file)}", add=1)
|
||||
self.Progress(statut=self.translate("Recompilation de")+f"\n{get_nodir(file)}", add=1)
|
||||
subprocess.call(["./tools/szs/wszst", "CREATE", file + ".d", "-d", file,
|
||||
"--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
if os.path.exists(file + ".d"): shutil.rmtree(file + ".d")
|
||||
|
||||
self.Progress(statut=f"Patch main.dol", add=1)
|
||||
self.Progress(statut=self.translate("Patch main.dol"), add=1)
|
||||
subprocess.call(["./tools/szs/wstrt", "patch", self.path_mkwf + "/sys/main.dol", "--clean-dol",
|
||||
"--add-lecode"], creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
self.Progress(statut=f"Patch lecode-PAL.bin", add=1)
|
||||
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
||||
|
||||
subprocess.call(
|
||||
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf + "/files/rel/lecode-PAL.bin",
|
||||
|
@ -95,7 +95,7 @@ def install_mod(self):
|
|||
"./file/CTFILE.txt", "--lpar", "./file/lpar-default.txt", "--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
outputformat = self.listbox_outputformat.get()
|
||||
self.Progress(statut=f"Conversion en {outputformat}", add=1)
|
||||
self.Progress(statut=self.translate("Conversion en")+" {outputformat}", add=1)
|
||||
|
||||
if outputformat in ["ISO", "WBFS", "CISO"]:
|
||||
self.path_mkwf_format = os.path.realpath(self.path_mkwf + "/../MKWFaraphel." + outputformat.lower())
|
||||
|
@ -104,12 +104,12 @@ def install_mod(self):
|
|||
, creationflags=CREATE_NO_WINDOW)
|
||||
shutil.rmtree(self.path_mkwf)
|
||||
|
||||
self.Progress(statut=f"Changement de l'ID du jeu", add=1)
|
||||
self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1)
|
||||
subprocess.call(["./tools/wit/wit", "EDIT", self.path_mkwf_format, "--id", "RMCP60"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
self.Progress(show=False)
|
||||
messagebox.showinfo("Fin", "L'installation est terminé !")
|
||||
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
||||
|
||||
t = Thread(target=func)
|
||||
t.setDaemon(True)
|
||||
|
|
|
@ -15,16 +15,16 @@ def patch_file(self):
|
|||
with open("./convert_file.json") as f:
|
||||
fc = json.load(f)
|
||||
max_step = len(fc["img"]) + len(fc["bmg"]) + total_track + 1
|
||||
self.Progress(show=True, indeter=False, statut="Conversion des fichiers", max=max_step, step=0)
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Conversion des fichiers"), max=max_step, step=0)
|
||||
|
||||
for i, file in enumerate(fc["img"]):
|
||||
self.Progress(statut=f"Conversion des images\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
||||
self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
||||
if not (os.path.exists("./file/" + get_filename(file))):
|
||||
subprocess.call(["./tools/szs/wimgt", "ENCODE", "./file/" + file, "-x", fc["img"][file]]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
for i, file in enumerate(fc["bmg"]):
|
||||
self.Progress(statut=f"Conversion des textes\n({i + 1}/{len(fc['bmg'])}) {file}", add=1)
|
||||
self.Progress(statut=self.translate("Conversion des textes")+f"\n({i + 1}/{len(fc['bmg'])}) {file}", add=1)
|
||||
if not (os.path.exists("./file/" + get_filename(file) + ".bmg")):
|
||||
subprocess.call(["./tools/szs/wbmgt", "ENCODE", "./file/" + file]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
@ -40,7 +40,7 @@ def patch_file(self):
|
|||
while True:
|
||||
if len(process_list) < max_process:
|
||||
process_list[file] = None
|
||||
self.Progress(statut=f"Conversion des courses\n({i + 1}/{total_track})\n" +
|
||||
self.Progress(statut=self.translate("Conversion des courses")+f"\n({i + 1}/{total_track})\n" +
|
||||
"\n".join(process_list.keys()), add=1)
|
||||
|
||||
if not (os.path.exists("./file/Track/" + get_filename(file) + ".szs")):
|
||||
|
@ -59,7 +59,7 @@ def patch_file(self):
|
|||
process_list.pop(process)
|
||||
break
|
||||
|
||||
self.Progress(statut="Création de LE-CODE", add=1)
|
||||
self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1)
|
||||
self.create_lecode_config()
|
||||
|
||||
self.Progress(show=False)
|
||||
|
|
9
source/translate.py
Normal file
9
source/translate.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import json
|
||||
|
||||
def translate(self, text):
|
||||
with open("./translation.json") as f:
|
||||
translation = json.load(f)
|
||||
if self.language in translation:
|
||||
_lang_trad = translation[self.language]
|
||||
if text in _lang_trad: return _lang_trad[text]
|
||||
return text
|
39
translation.json
Normal file
39
translation.json
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"en": {
|
||||
"MKWFaraphel Installateur": "MKWFaraphel Installer",
|
||||
"Jeu Wii": "Wii game",
|
||||
"Jeu original": "Original game",
|
||||
"Erreur": "Error",
|
||||
"Le chemin de fichier est invalide": "The file path in invalid",
|
||||
"Attention": "Warning",
|
||||
"Ce dossier sera écrasé si vous installer le mod !\nÊtes-vous sûr de vouloir l'utiliser ?": "This directory will be overwritten if you install the mod !\nAre you sure you want to use it ?",
|
||||
"Extraction du jeu...": "Extracting the game...",
|
||||
"Le type de fichier n'est pas reconnu": "This file type is not supported",
|
||||
"Cette ROM est déjà moddé, il est déconseillé de l'utiliser pour installer le mod": "This game is already modded, it is not recommended to use it to install the mod",
|
||||
"Extraire le fichier": "Extract file",
|
||||
"Preparer les fichiers": "Prepare files",
|
||||
"Action": "Action",
|
||||
"Installer le mod": "Install mod",
|
||||
"Dossier": "Directory",
|
||||
|
||||
"Mise à jour disponible !": "Update available !",
|
||||
"Une mise à jour est disponible, souhaitez-vous l'installer ?": "An update is available, do you want to install it ?",
|
||||
"Téléchargement de Updater en cours...": "Downloading the Updater...",
|
||||
"fin du téléchargement, début de l'extraction...": "end of the download, extracting...",
|
||||
"fin de l'extraction": "finished extracting",
|
||||
"lancement de l'application...": "starting application...",
|
||||
|
||||
"Modification de": "Modifying",
|
||||
"Recompilation de": "Recompilating",
|
||||
"Conversion en": "Converting to",
|
||||
"Changement de l'ID du jeu": "editing game's ID",
|
||||
"Fin": "End",
|
||||
"L'installation est terminé !": "The mod has been installed !",
|
||||
|
||||
"Conversion des fichiers": "Converting files",
|
||||
"Conversion des images": "Converting images",
|
||||
"Conversion des textes": "Converting texts",
|
||||
"Conversion des courses": "Converting races",
|
||||
"Configuration de LE-CODE": "Configurating LE-CODE"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue