Added language support for German

This commit is contained in:
2025-06-18 00:04:09 +02:00
parent 5b7cc4de97
commit 5740b22583
14 changed files with 275 additions and 133 deletions

View File

@ -1,7 +1,6 @@
import locale
import gettext
import tkinter as tk
from pathlib import Path
from tkinter import ttk
import os
import subprocess
@ -10,10 +9,10 @@ from network import GiteaUpdate
class LXToolsAppConfig:
VERSION = "1.1.4"
APP_NAME = "Lunix Tools Installer"
VERSION = "1.1.5"
APP_NAME = "lxtoolsinstaller"
WINDOW_WIDTH = 450
WINDOW_HEIGHT = 580
WINDOW_HEIGHT = 740
# Working directory
WORK_DIR = os.getcwd()
@ -21,7 +20,7 @@ class LXToolsAppConfig:
THEMES_DIR = os.path.join(WORK_DIR, "TK-Themes")
# Locale settings
LOCALE_DIR = Path("/usr/share/locale/")
LOCALE_DIR = "./locale/"
# Download URLs
WIREPY_URL = "https://git.ilunix.de/punix/Wire-Py/archive/main.zip"
@ -94,7 +93,7 @@ class LXToolsAppConfig:
}
@staticmethod
def setup_translations():
def setup_translations() -> gettext.gettext:
"""Initialize translations and set the translation function"""
try:
locale.bindtextdomain(
@ -113,6 +112,117 @@ class LXToolsAppConfig:
_ = LXToolsAppConfig.setup_translations()
class LocaleStrings:
MSGI = {
"refresh_and_check": _("Refreshing status and checking versions..."),
"start_install": _("Starting installation of "),
"install": _("Installing "),
"install_success": _(" installation successfully!"),
"install_failed": _("Installation failed: "),
"install_create": _("Created install script: "),
"install_script_failed": _("Installation script failed: "),
"install_timeout": _("Installation timed out"),
"installed": _("Installed "),
}
MSGU = {
"uninstall": _("Uninstalling "),
"uninstall_success": _(" uninstalled successfully!"),
"uninstall_failed": _("Uninstallation failed: "),
"uninstall_create": _("Created uninstall script: "),
"uninstall_script_failed": _("Uninstallation script failed: "),
"uninstall_timeout": _("Uninstallation timed out"),
}
# MSGO = Other messages
MSGO = {
"unknown_project": _("Unknown project: "),
"not_install": _(" is not installed."),
"download_from": _("Downloading from "),
"extract_files": _("Extracting files..."),
"download_failed": _("Download failed: "),
"head_string2": _("System: "),
"head_string3": _("Linux App Installer"),
"ready": _("Ready for installation"),
"no_internet": _("No internet connection"),
"repo_unavailable": _("Repository unavailable"),
"system_check": _("System checking..."),
"applications": _("Applications"),
"progress": _("Progress"),
"refresh2": _("Status refresh completed"),
}
# MSGC = Strings on Cards
MSGC = {
"checking": _("Checking..."),
"version_check": _("Version: Checking..."),
"latest": _("Latest: "),
"update_available": _("Update available "),
"up_to_date": _("Up to date"),
"latest_unknown": _("Latest unknown"),
"could_not_check": _("Could not check latest version"),
"check_last_failed": _("Latest: Check failed"),
"version_check_failed": _("Version check failed"),
"not_installed": _("Not installed"),
"available": _("Available "),
"available_unknown": _("Available unknown"),
"available_ckeck_failed": _("Available: Check failed"),
}
# MSGL = Strings on Logmessages
MSGL = {
"selected_app": _("Selected project: "),
"log_name": _("Installation Log"),
"work_dir": _("Working directory: "),
"icons_dir": _("Icons directory: "),
"detected_os": _("Detected OS: "),
"log_cleared": _("Log cleared"),
"working_dir": _("Working directory: "),
"user_interuppt": _("\nApplication interrupted by user."),
"fatal_error": _("Fatal error: "),
"fatal_app_error": _("Fatal Error Application failed to start: "),
}
# MSGB = Strings on Buttons
MSGB = {
"clear_log": _("Clear Log"),
"install": _("Install/Update"),
"uninstall": _("Uninstall"),
"refresh": _("Refresh Status"),
}
# MSGM = String on MessagDialogs
MSGM = {
"please_select": _("Please select a project to install."),
"network_error": _(
"No internet connection available.\nPlease check your network connection.",
),
"repo_error": _(
"Cannot access repository.\nPlease try again later.",
),
"has_success_update": _("has been successfully installed/updated."),
"please_select_uninstall": _("Please select a project to uninstall."),
}
# MSGP = Others print strings
MSGP = {
"tk_install": _("Installing tkinter for )"),
"command_string": _("Command: "),
"tk_success": _("TKinter installation completed successfully!"),
"tk_failed": _("TKinter installation failed: "),
"tk_timeout": _("TKinter installation timed out"),
"tk_install_error": _("Error installing tkinter: "),
"tk_command_error": _("No tkinter installation command defined for "),
"fail_load_image": _("Failed to load image from "),
"logviewer_check": _("LogViewer installation check:"),
"symlink_exist": _(" Symlink exists: "),
"executable_exist": _(" Executable exists: "),
"is_executable": _(" Is executable: "),
"final_result": _(" Final result: "),
"get_version_error": _("Error getting version for "),
}
class OSDetector:
@staticmethod
def detect_os():
@ -148,8 +258,8 @@ class OSDetector:
if detected_os in LXToolsAppConfig.TKINTER_INSTALL_COMMANDS:
commands = LXToolsAppConfig.TKINTER_INSTALL_COMMANDS[detected_os]
print(f"Installing tkinter for {detected_os}...")
print(_(f"Command: {' '.join(commands)}"))
print(f"{LocaleStrings.MSGP["tk_install"]}{detected_os}...")
print(f"{LocaleStrings.MSGP["command_string"]}{' '.join(commands)}")
try:
# Use pkexec for privilege escalation
@ -159,20 +269,20 @@ class OSDetector:
)
if result.returncode == 0:
print(_("TKinter installation completed successfully!"))
print(f"{LocaleStrings.MSGP["tk_succcess"]}")
return True
else:
print(_(f"TKinter installation failed: {result.stderr}"))
print(f"{LocaleStrings.MSGP["tk_failed"]}{result.stderr}")
return False
except subprocess.TimeoutExpired:
print(_("TKinter installation timed out"))
print(LocaleStrings.MSGP["tk_timeout"])
return False
except Exception as e:
print(_(f"Error installing tkinter: {e}"))
print(f"{LocaleStrings.MSGP['tk_install_error']}{str(e)}")
return False
else:
print(_(f"No tkinter installation command defined for {detected_os}"))
print(f"{LocaleStrings.MSGP["tk_command_error"]}{detected_os}")
return False
@ -307,7 +417,7 @@ class Image:
self.images[image_key] = photo
return photo
except tk.TclError as e:
print(_(f"Failed to load image from {path}: {e}"))
print(f"{LocaleStrings.MSGP["fail_load_image"]}{path}: {e}")
continue
# Return None if no image found
@ -356,11 +466,11 @@ class AppManager:
)
# Debug logging
print(_("LogViewer installation check:"))
print(_(f" Symlink exists: {symlink_exists}"))
print(_(f" Executable exists: {executable_exists}"))
print(_(f" Is executable: {executable_is_executable}"))
print(_(f" Final result: {is_installed}"))
print(LocaleStrings.MSGP["logviewer_check"])
print(f"{LocaleStrings.MSGP["symlink_exist"]}{symlink_exists}")
print(f"{LocaleStrings.MSGP["executable_exist"]}{executable_exists}")
print(f"{LocaleStrings.MSGP["is_executable"]}{executable_is_executable}")
print(f"{LocaleStrings.MSGP["final_result"]}{is_installed}")
return is_installed
@ -385,7 +495,7 @@ class AppManager:
return version
return "Unknown"
except Exception as e:
print(_(f"Error getting version for {project_key}: {e}"))
print(f"{LocaleStrings.MSGP["get_version_error"]}{project_key}: {e}")
return "Unknown"
def get_latest_version(self, project_key):