mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 18:58:27 +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": {
|
||||
"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 !",
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
"USE": "Use",
|
||||
"THREADS": "threads",
|
||||
"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",
|
||||
"SPECIFIC_MOD_SETTINGS": "Specific mod settings",
|
||||
"CONFIGURE_MYSTUFF_PATCH": "Configure the MyStuff patchs",
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
"USE": "Utiliser",
|
||||
"THREADS": "threads",
|
||||
"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",
|
||||
"SPECIFIC_MOD_SETTINGS": "Paramètre spécifique de mod",
|
||||
"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.option import Option
|
||||
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 *
|
||||
import os
|
||||
|
@ -432,15 +432,17 @@ class ButtonInstall(ttk.Button):
|
|||
)
|
||||
)
|
||||
|
||||
message_texts = mod_config.messages.get("installation_completed", {}).get("text", {})
|
||||
message = message_texts.get(self.root.options["language"])
|
||||
if message is None: message = message_texts.get("*")
|
||||
if message is None: message = _('NO_MESSAGE_FROM_AUTHOR')
|
||||
message = mod_config.multiple_safe_eval(message)()
|
||||
message: str = translate_external(
|
||||
mod_config,
|
||||
self.root.options["language"],
|
||||
mod_config.messages.get("installation_completed", {}).get("text", {})
|
||||
)
|
||||
|
||||
messagebox.showinfo(
|
||||
_("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:
|
||||
|
|
|
@ -2,7 +2,7 @@ import tkinter
|
|||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from source.translation import translate as _
|
||||
from source.translation import translate as _, translate_external
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from source.mkw.ModConfig import ModConfig
|
||||
|
@ -63,9 +63,11 @@ class FrameSettings(ttk.Frame):
|
|||
return lambda event: enabled_variable.set(True)
|
||||
|
||||
for index, (settings_name, settings_data) in enumerate(settings.items()):
|
||||
text = settings_data.text.get(self.root.options["language"])
|
||||
if text is None: text = settings_data.text.get("*")
|
||||
if text is None: text = settings_name
|
||||
text = translate_external(
|
||||
self.master.master.mod_config,
|
||||
self.root.options["language"],
|
||||
settings_data.text,
|
||||
)
|
||||
|
||||
enabled_variable = tkinter.BooleanVar(value=False)
|
||||
checkbox = ttk.Checkbutton(self, text=text, variable=enabled_variable)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from source.mkw.ModConfig import ModConfig
|
||||
|
||||
|
||||
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