language works in appimage

This commit is contained in:
2025-06-21 11:09:48 +02:00
parent a63d54f128
commit 01bd6ab263
2 changed files with 37 additions and 42 deletions

View File

@ -16,7 +16,6 @@ from manager import (
Image, Image,
AppManager, AppManager,
LxTools, LxTools,
EnsureFiles,
) )
from network import NetworkChecker from network import NetworkChecker
from message import MessageDialog from message import MessageDialog
@ -1336,7 +1335,6 @@ def main():
try: try:
# Create and run the GUI # Create and run the GUI
EnsureFiles.extract_data_files()
app = LXToolsGUI() app = LXToolsGUI()
app.run() app.run()
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -94,6 +94,42 @@ class LXToolsAppConfig:
"SUSE Leap": ["zypper", "install", "-y", "python312-tk"], "SUSE Leap": ["zypper", "install", "-y", "python312-tk"],
} }
@staticmethod
def extract_data_files():
if getattr(sys, "_MEIPASS", None) is not None:
# Liste der Quellordner (entspricht dem "datas"-Eintrag in lxtools_installer.spec)
source_dirs = [
os.path.join(sys._MEIPASS, "locale"), # für locale/...
os.path.join(sys._MEIPASS, "TK-Themes"), # für TK-Themes/...
os.path.join(sys._MEIPASS, "lx-icons"), # für lx-icons/...
]
target_dir = os.path.abspath(
os.getcwd()
) # Zielverzeichnis: aktueller Ordner
for source_dir in source_dirs:
group_name = os.path.basename(
source_dir
) # Erhält den Gruppen-Name (z.B. 'locale', 'TK-Themes')
for root, dirs, files in os.walk(source_dir):
for file in files:
src_path = os.path.join(root, file)
# Relativer Pfad innerhalb des Quellordners
rel_path_from_source_root = os.path.relpath(
src_path, source_dir
)
# Ziel-Pfad unter dem Gruppen-Ordner im aktuellen Verzeichnis
dst_path = os.path.join(
target_dir, group_name, rel_path_from_source_root
)
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
shutil.copy2(src_path, dst_path)
@staticmethod @staticmethod
def setup_translations() -> gettext.gettext: def setup_translations() -> gettext.gettext:
"""Initialize translations and set the translation function""" """Initialize translations and set the translation function"""
@ -110,6 +146,7 @@ class LXToolsAppConfig:
return gettext.gettext return gettext.gettext
LXToolsAppConfig.extract_data_files()
# Initialize translations # Initialize translations
_ = LXToolsAppConfig.setup_translations() _ = LXToolsAppConfig.setup_translations()
@ -288,46 +325,6 @@ class OSDetector:
return False return False
class EnsureFiles:
"""ckeck start as appimage andd extract data files"""
@staticmethod
def extract_data_files():
if getattr(sys, "_MEIPASS", None) is not None:
# Liste der Quellordner (entspricht dem "datas"-Eintrag in lxtools_installer.spec)
source_dirs = [
os.path.join(sys._MEIPASS, "locale"), # für locale/...
os.path.join(sys._MEIPASS, "TK-Themes"), # für TK-Themes/...
os.path.join(sys._MEIPASS, "lx-icons"), # für lx-icons/...
]
target_dir = os.path.abspath(
os.getcwd()
) # Zielverzeichnis: aktueller Ordner
for source_dir in source_dirs:
group_name = os.path.basename(
source_dir
) # Erhält den Gruppen-Name (z.B. 'locale', 'TK-Themes')
for root, dirs, files in os.walk(source_dir):
for file in files:
src_path = os.path.join(root, file)
# Relativer Pfad innerhalb des Quellordners
rel_path_from_source_root = os.path.relpath(
src_path, source_dir
)
# Ziel-Pfad unter dem Gruppen-Ordner im aktuellen Verzeichnis
dst_path = os.path.join(
target_dir, group_name, rel_path_from_source_root
)
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
shutil.copy2(src_path, dst_path)
class Theme: class Theme:
@staticmethod @staticmethod
def apply_light_theme(root): def apply_light_theme(root):