mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
added translate_external for message that need translation from outside of the installer.
This commit is contained in:
parent
d3ca353ecd
commit
433bf08b9b
6 changed files with 38 additions and 13 deletions
|
@ -1,4 +1,10 @@
|
||||||
{
|
{
|
||||||
|
"specific_settings_description": {
|
||||||
|
"text": {
|
||||||
|
"fr": "* Ceci activera le mode \"triche\"",
|
||||||
|
"en": "* This will enable the \"cheat\" mode"
|
||||||
|
}
|
||||||
|
},
|
||||||
"installation_completed": {
|
"installation_completed": {
|
||||||
"text": {
|
"text": {
|
||||||
"fr": "Merci d'avoir téléchargé {{ mod_config.name }} !\nSi vous avez un problème en démarrant le jeu avec Dolphin, essayer dans Configurer > Avancé > Modifier la taille de la mémoire émulée et mettre MEM2 à 128MB\n\nAmusez-vous !",
|
"fr": "Merci d'avoir téléchargé {{ mod_config.name }} !\nSi vous avez un problème en démarrant le jeu avec Dolphin, essayer dans Configurer > Avancé > Modifier la taille de la mémoire émulée et mettre MEM2 à 128MB\n\nAmusez-vous !",
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
"USE": "Use",
|
"USE": "Use",
|
||||||
"THREADS": "threads",
|
"THREADS": "threads",
|
||||||
"MESSAGE_FROM_MOD_AUTHOR": "Message from the author",
|
"MESSAGE_FROM_MOD_AUTHOR": "Message from the author",
|
||||||
"NO_MESSAGE_FROM_AUTHOR": "< The author didn't left any message >",
|
|
||||||
"GLOBAL_MOD_SETTINGS": "Global mod settings",
|
"GLOBAL_MOD_SETTINGS": "Global mod settings",
|
||||||
"SPECIFIC_MOD_SETTINGS": "Specific mod settings",
|
"SPECIFIC_MOD_SETTINGS": "Specific mod settings",
|
||||||
"CONFIGURE_MYSTUFF_PATCH": "Configure the MyStuff patchs",
|
"CONFIGURE_MYSTUFF_PATCH": "Configure the MyStuff patchs",
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
"USE": "Utiliser",
|
"USE": "Utiliser",
|
||||||
"THREADS": "threads",
|
"THREADS": "threads",
|
||||||
"MESSAGE_FROM_MOD_AUTHOR": "Message de l'auteur",
|
"MESSAGE_FROM_MOD_AUTHOR": "Message de l'auteur",
|
||||||
"NO_MESSAGE_FROM_AUTHOR": "< L'auteur n'a pas laissé de message >",
|
|
||||||
"GLOBAL_MOD_SETTINGS": "Paramètre global de mod",
|
"GLOBAL_MOD_SETTINGS": "Paramètre global de mod",
|
||||||
"SPECIFIC_MOD_SETTINGS": "Paramètre spécifique de mod",
|
"SPECIFIC_MOD_SETTINGS": "Paramètre spécifique de mod",
|
||||||
"CONFIGURE_MYSTUFF_PATCH": "Configurer les patchs MyStuff",
|
"CONFIGURE_MYSTUFF_PATCH": "Configurer les patchs MyStuff",
|
||||||
|
|
|
@ -14,7 +14,7 @@ from source.mkw.Game import Game
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
||||||
from source.option import Option
|
from source.option import Option
|
||||||
from source.progress import Progress
|
from source.progress import Progress
|
||||||
from source.translation import translate as _
|
from source.translation import translate as _, translate_external
|
||||||
from source import plugins
|
from source import plugins
|
||||||
from source import *
|
from source import *
|
||||||
import os
|
import os
|
||||||
|
@ -432,15 +432,17 @@ class ButtonInstall(ttk.Button):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
message_texts = mod_config.messages.get("installation_completed", {}).get("text", {})
|
message: str = translate_external(
|
||||||
message = message_texts.get(self.root.options["language"])
|
mod_config,
|
||||||
if message is None: message = message_texts.get("*")
|
self.root.options["language"],
|
||||||
if message is None: message = _('NO_MESSAGE_FROM_AUTHOR')
|
mod_config.messages.get("installation_completed", {}).get("text", {})
|
||||||
message = mod_config.multiple_safe_eval(message)()
|
)
|
||||||
|
|
||||||
messagebox.showinfo(
|
messagebox.showinfo(
|
||||||
_("INSTALLATION_COMPLETED"),
|
_("INSTALLATION_COMPLETED"),
|
||||||
f"{_('INSTALLATION_FINISHED_WITH_SUCCESS')}\n{_('MESSAGE_FROM_MOD_AUTHOR')} :\n\n{message}"
|
f"{_('INSTALLATION_FINISHED_WITH_SUCCESS')}" + (
|
||||||
|
f"\n{_('MESSAGE_FROM_MOD_AUTHOR')} :\n\n{message}" if message != "" else ""
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -2,7 +2,7 @@ import tkinter
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from source.translation import translate as _
|
from source.translation import translate as _, translate_external
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from source.mkw.ModConfig import ModConfig
|
from source.mkw.ModConfig import ModConfig
|
||||||
|
@ -63,9 +63,11 @@ class FrameSettings(ttk.Frame):
|
||||||
return lambda event: enabled_variable.set(True)
|
return lambda event: enabled_variable.set(True)
|
||||||
|
|
||||||
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
||||||
text = settings_data.text.get(self.root.options["language"])
|
text = translate_external(
|
||||||
if text is None: text = settings_data.text.get("*")
|
self.master.master.mod_config,
|
||||||
if text is None: text = settings_name
|
self.root.options["language"],
|
||||||
|
settings_data.text,
|
||||||
|
)
|
||||||
|
|
||||||
enabled_variable = tkinter.BooleanVar(value=False)
|
enabled_variable = tkinter.BooleanVar(value=False)
|
||||||
checkbox = ttk.Checkbutton(self, text=text, variable=enabled_variable)
|
checkbox = ttk.Checkbutton(self, text=text, variable=enabled_variable)
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from source.mkw.ModConfig import ModConfig
|
||||||
|
|
||||||
|
|
||||||
self = __import__(__name__)
|
self = __import__(__name__)
|
||||||
|
@ -28,5 +32,18 @@ def translate(*text) -> str:
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
def translate_external(mod_config: "ModConfig", language: str, message_texts: dict[str, str], default: str = "") -> str:
|
||||||
|
"""
|
||||||
|
Translate any message that is not from the game.
|
||||||
|
:param mod_config: the ModConfig object
|
||||||
|
:param language: the language to translate to
|
||||||
|
:param message_texts: a dictionary with the translation
|
||||||
|
:param default: the default message if no translation are found
|
||||||
|
:return: the translated message
|
||||||
|
"""
|
||||||
|
message = message_texts.get(language)
|
||||||
|
if message is None: message = message_texts.get("*")
|
||||||
|
if message is None: message = default
|
||||||
|
return mod_config.multiple_safe_eval(message)()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue