Add internationalization support with English and French translations
- Introduced a new i18n module for managing translations using JSON files. - Added English (en.json) and French (fr.json) translation files for UI elements. - Implemented lazy initialization of the translator to load translations on demand. - Added unit tests for translation lookup, fallback behavior, and available languages detection.
This commit is contained in:
parent
fd0482ed2d
commit
7daec731ca
11 changed files with 1184 additions and 280 deletions
|
|
@ -81,6 +81,7 @@ class Config:
|
|||
window_title: str = ""
|
||||
enable_logging: bool = True
|
||||
enable_checkout: bool = False
|
||||
language: str = "auto"
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, config_path: Path) -> "Config":
|
||||
|
|
@ -172,6 +173,7 @@ class Config:
|
|||
window_title=window_title,
|
||||
enable_logging=data.get("enable_logging", True),
|
||||
enable_checkout=data.get("enable_checkout", False),
|
||||
language=data.get("language", "auto"),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -212,6 +214,7 @@ class Config:
|
|||
window_title = os.getenv("WINDOW_TITLE", default_title)
|
||||
enable_logging = os.getenv("ENABLE_LOGGING", "true").lower() == "true"
|
||||
enable_checkout = os.getenv("ENABLE_CHECKOUT", "false").lower() == "true"
|
||||
language = os.getenv("LANGUAGE", "auto")
|
||||
|
||||
# Validate log level
|
||||
valid_levels = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
|
||||
|
|
@ -304,6 +307,7 @@ class Config:
|
|||
window_title=window_title,
|
||||
enable_logging=enable_logging,
|
||||
enable_checkout=enable_checkout,
|
||||
language=language,
|
||||
)
|
||||
|
||||
def to_file(self, config_path: Path) -> None:
|
||||
|
|
@ -332,6 +336,7 @@ class Config:
|
|||
"window_title": self.window_title,
|
||||
"enable_logging": self.enable_logging,
|
||||
"enable_checkout": self.enable_checkout,
|
||||
"language": self.language,
|
||||
}
|
||||
|
||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue