Translations, suggestion box, UX
All checks were successful
Gitea/kapitanbooru-uploader/pipeline/head This commit looks good

This commit is contained in:
2025-03-03 00:47:38 +01:00
parent 9f187afc22
commit 9361bc0363
17 changed files with 1515 additions and 135 deletions

View File

@@ -1,11 +1,11 @@
import base64
import importlib
import json
import os
import sqlite3
import subprocess
import sys
from .I18N import _
# Na Windowsie używamy DPAPI
if sys.platform.startswith("win"):
try:
@@ -49,6 +49,7 @@ def get_browser_paths_windows():
return browsers
def get_browsers_linux():
"""Detects installed browsers on Linux by checking available executables."""
browsers = {"Default": None}
@@ -114,6 +115,7 @@ class Settings:
self.default_tags = "artist:kapitan meta:ai-generated"
self.cache_expiry = 604800 # 7 dni w sekundach
self.browser = ""
self.i18n = _
self.installed_browsers = detect_installed_browsers()
self.load_settings()
self.installed_browsers_reverse = {
@@ -139,6 +141,7 @@ class Settings:
self.default_tags = "artist:kapitan meta:ai-generated"
self.cache_expiry = 604800 # 7 dni w sekundach
self.browser = ""
self.i18n.set_language("en")
try:
if os.path.exists(self.get_settings_path()):
with open(self.get_settings_path(), "r", encoding="utf-8") as f:
@@ -155,8 +158,9 @@ class Settings:
self.browser = data.get("browser", self.browser)
if self.browser not in self.installed_browsers:
self.browser = ""
self.i18n.set_language(data.get("language", "en"))
except Exception as e:
print("Błąd podczas ładowania ustawień:", e)
print(_("Błąd podczas ładowania ustawień:"), e)
def save_settings(self):
"""Zapisuje ustawienia do pliku."""
@@ -166,6 +170,7 @@ class Settings:
"default_tags": self.default_tags,
"cache_expiry": self.cache_expiry,
"browser": self.browser,
"language": self.i18n.current_lang,
}
# Na Windowsie szyfrujemy hasło
if sys.platform.startswith("win"):
@@ -176,4 +181,4 @@ class Settings:
with open(self.get_settings_path(), "w", encoding="utf-8") as f:
json.dump(data, f, indent=4)
except Exception as e:
print("Błąd podczas zapisywania ustawień:", e)
print(_("Błąd podczas zapisywania ustawień:"), e)