You've already forked wakapi-readme-stats
code style applied to main
This commit is contained in:
25
sources/manager_localization.py
Normal file
25
sources/manager_localization.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from json import load
|
||||
from os.path import join, dirname
|
||||
from typing import Dict
|
||||
|
||||
from manager_environment import EnvironmentManager as EM
|
||||
|
||||
|
||||
def init_localization_manager():
|
||||
"""
|
||||
"""
|
||||
LocalizationManager.load_localization("translation.json")
|
||||
|
||||
|
||||
class LocalizationManager:
|
||||
_LOCALIZATION: Dict[str, str] = dict()
|
||||
|
||||
@staticmethod
|
||||
def load_localization(file: str):
|
||||
with open(join(dirname(__file__), file), encoding='utf-8') as config_file:
|
||||
data = load(config_file)
|
||||
LocalizationManager._LOCALIZATION = data[EM.LOCALE]
|
||||
|
||||
@staticmethod
|
||||
def t(key: str) -> str:
|
||||
return LocalizationManager._LOCALIZATION[key]
|
||||
Reference in New Issue
Block a user