mirror of
https://github.com/OMGeeky/Kivy-Shopping-List.git
synced 2026-01-21 18:58:36 +01:00
fix lang files path
This commit is contained in:
@@ -4,10 +4,11 @@ from typing import Dict, Optional
|
||||
|
||||
|
||||
LANGUAGES = {"DE": "Deutsch", "EN": "English", "FR": "Francais"}
|
||||
LANGUAGE_FOLDER = Path("src","res", "lang")
|
||||
LANGUAGE_FOLDER = Path("res", "lang")
|
||||
|
||||
|
||||
class TranslationProvider:
|
||||
src_dir : Path
|
||||
last_language_key: Optional[str] = None
|
||||
last_language_dict: Optional[Dict[str, str]] = None
|
||||
|
||||
@@ -19,7 +20,8 @@ class TranslationProvider:
|
||||
if cls.last_language_key == language and cls.last_language_dict is not None:
|
||||
return cls.last_language_dict
|
||||
|
||||
path = Path(LANGUAGE_FOLDER, f"{language}.json")
|
||||
path = Path(cls.src_dir, LANGUAGE_FOLDER, f"{language}.json")
|
||||
print(f"loading language file: {path}")
|
||||
try:
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
result = json.load(f)
|
||||
@@ -29,7 +31,7 @@ class TranslationProvider:
|
||||
|
||||
except FileNotFoundError:
|
||||
print(f'Language not found: "{language}"')
|
||||
raise
|
||||
return {}
|
||||
|
||||
@classmethod
|
||||
def get_translated(cls, key: str, language: str) -> str:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from pathlib import Path
|
||||
|
||||
from data import AppSettings
|
||||
from data.files import read_entries_from_files, write_entries_to_files
|
||||
from language import TranslationProvider, LANGUAGES
|
||||
@@ -321,7 +323,9 @@ class ShoppingListApp(MDApp):
|
||||
self.title = "Shopping List App"
|
||||
self.settings = AppSettings.get_or_create()
|
||||
print(self.settings)
|
||||
|
||||
print(self.user_data_dir)
|
||||
print(self.directory)
|
||||
TranslationProvider.src_dir = Path(self.directory)
|
||||
|
||||
# TODO @Tom Theme anpassen
|
||||
self.theme_cls.primary_palette = "Gray"
|
||||
|
||||
Reference in New Issue
Block a user