Added logic to load translations and to translate texts
This commit is contained in:
29
src/cpl_translation/translation_settings.py
Normal file
29
src/cpl_translation/translation_settings.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import traceback
|
||||
|
||||
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||
from cpl_core.console import Console
|
||||
|
||||
|
||||
class TranslationSettings(ConfigurationModelABC):
|
||||
|
||||
def __init__(self):
|
||||
ConfigurationModelABC.__init__(self)
|
||||
|
||||
self._languages = []
|
||||
self._default_lang = ''
|
||||
|
||||
@property
|
||||
def languages(self) -> list[str]:
|
||||
return self._languages
|
||||
|
||||
@property
|
||||
def default_language(self) -> str:
|
||||
return self._default_lang
|
||||
|
||||
def from_dict(self, settings: dict):
|
||||
try:
|
||||
self._languages = settings['Languages']
|
||||
self._default_lang = settings['DefaultLanguage']
|
||||
except Exception as e:
|
||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||
Reference in New Issue
Block a user