mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-06 04:38:29 +02:00
fully added language, we can now change it from a combobox, and app will automaticly restart
This commit is contained in:
parent
1d101cf26b
commit
e0ffdc01ac
5 changed files with 43 additions and 49 deletions
6
main.pyw
6
main.pyw
|
@ -13,17 +13,17 @@ from source.definition import *
|
||||||
|
|
||||||
class ClassApp():
|
class ClassApp():
|
||||||
from source.__init__ import __init__
|
from source.__init__ import __init__
|
||||||
from source.translate import translate
|
from source.translate import translate, change_language, get_language
|
||||||
from source.Progress import Progress
|
from source.Progress import Progress
|
||||||
from source.check_update import check_update
|
from source.check_update import check_update
|
||||||
from source.StateButton import StateButton
|
from source.StateButton import StateButton
|
||||||
from source.create_lecode_config import create_lecode_config
|
from source.create_lecode_config import create_lecode_config
|
||||||
from source.patch_file import patch_file
|
from source.patch_file import patch_file
|
||||||
from source.install_mod import install_mod
|
from source.install_mod import install_mod
|
||||||
|
from source.restart import restart
|
||||||
|
|
||||||
|
|
||||||
# TODO: Langue
|
|
||||||
# TODO: Wiki Github
|
# TODO: Wiki Github
|
||||||
# TODO: Autogénération des bmg
|
# TODO: Autogénération des bmg
|
||||||
App = ClassApp()
|
App = ClassApp()
|
||||||
mainloop()
|
App.root.mainloop()
|
|
@ -8,21 +8,31 @@ from .definition import *
|
||||||
from .check_update import check_update
|
from .check_update import check_update
|
||||||
from .translate import translate
|
from .translate import translate
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.language = "fr"
|
self.language = self.get_language()
|
||||||
|
|
||||||
self.root = Tk()
|
self.root = Tk()
|
||||||
self.root.title(self.translate("MKWFaraphel Installateur"))
|
self.root.title(self.translate("MKWFaraphel Installateur"))
|
||||||
self.root.resizable(False, False)
|
self.root.resizable(False, False)
|
||||||
self.root.iconbitmap(bitmap="./icon.ico")
|
self.root.iconbitmap(bitmap="./icon.ico")
|
||||||
|
|
||||||
self.frame_game_path = LabelFrame(self.root, text=self.translate("Jeu original"))
|
|
||||||
self.frame_game_path.grid(row=1, column=1)
|
|
||||||
|
|
||||||
self.check_update()
|
self.check_update()
|
||||||
self.path_mkwf = None
|
self.path_mkwf = None
|
||||||
|
|
||||||
|
self.frame_language = Frame(self.root)
|
||||||
|
self.frame_language.grid(row=1, column=1, sticky="E")
|
||||||
|
|
||||||
|
Label(self.frame_language, text=self.translate("Langage : ")).grid(row=1, column=1)
|
||||||
|
self.listbox_language = ttk.Combobox(self.frame_language, values=["fr", "en"], width=5)
|
||||||
|
self.listbox_language.set(self.language)
|
||||||
|
self.listbox_language.grid(row=1, column=2)
|
||||||
|
|
||||||
|
|
||||||
|
self.listbox_language.bind("<<ComboboxSelected>>", lambda x: self.change_language())
|
||||||
|
|
||||||
|
self.frame_game_path = LabelFrame(self.root, text=self.translate("Jeu original"))
|
||||||
|
self.frame_game_path.grid(row=2, column=1)
|
||||||
|
|
||||||
entry_game_path = Entry(self.frame_game_path, width=50)
|
entry_game_path = Entry(self.frame_game_path, width=50)
|
||||||
entry_game_path.grid(row=1, column=1, sticky="NEWS")
|
entry_game_path.grid(row=1, column=1, sticky="NEWS")
|
||||||
|
|
||||||
|
@ -71,7 +81,7 @@ def __init__(self):
|
||||||
self.translate("Cette ROM est déjà moddé, " +
|
self.translate("Cette ROM est déjà moddé, " +
|
||||||
"il est déconseillé de l'utiliser pour installer le mod"))
|
"il est déconseillé de l'utiliser pour installer le mod"))
|
||||||
|
|
||||||
self.frame_action.grid(row=2, column=1, sticky="NEWS")
|
self.frame_action.grid(row=3, column=1, sticky="NEWS")
|
||||||
self.Progress(show=False)
|
self.Progress(show=False)
|
||||||
|
|
||||||
t = Thread(target=func)
|
t = Thread(target=func)
|
||||||
|
|
7
source/restart.py
Normal file
7
source/restart.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def restart(self):
|
||||||
|
os.execl(sys.executable, f'"{sys.executable}"', *sys.argv)
|
||||||
|
sys.exit()
|
|
@ -1,9 +1,24 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def translate(self, text):
|
def translate(self, text):
|
||||||
with open("./translation.json", encoding="utf-8") as f:
|
with open("./translation.json", encoding="utf-8") as f:
|
||||||
translation = json.load(f)
|
translation = json.load(f)
|
||||||
if self.language in translation:
|
if self.language in translation:
|
||||||
_lang_trad = translation[self.language]
|
_lang_trad = translation[self.language]
|
||||||
if text in _lang_trad: return _lang_trad[text]
|
if text in _lang_trad: return _lang_trad[text]
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def change_language(self):
|
||||||
|
with open("./translation.json", encoding="utf-8") as f: translation = json.load(f)
|
||||||
|
translation["selected"] = self.listbox_language.get()
|
||||||
|
with open("./translation.json", "w", encoding="utf-8") as f: json.dump(translation, f)
|
||||||
|
|
||||||
|
self.restart()
|
||||||
|
|
||||||
|
|
||||||
|
def get_language(self):
|
||||||
|
with open("./translation.json", encoding="utf-8") as f: translation = json.load(f)
|
||||||
|
if "selected" in translation: return translation["selected"]
|
||||||
|
else: return "fr"
|
|
@ -1,39 +1 @@
|
||||||
{
|
{"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 \u00e9cras\u00e9 si vous installer le mod !\n\u00cates-vous s\u00fbr 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\u00e9j\u00e0 modd\u00e9, il est d\u00e9conseill\u00e9 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", "Langage : ": "Language : ", "Mise \u00e0 jour disponible !": "Update available !", "Une mise \u00e0 jour est disponible, souhaitez-vous l'installer ?": "An update is available, do you want to install it ?", "T\u00e9l\u00e9chargement de Updater en cours...": "Downloading the Updater...", "fin du t\u00e9l\u00e9chargement, d\u00e9but 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\u00e9 !": "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"}, "selected": "en"}
|
||||||
"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