Debugging..

This commit is contained in:
Maxim Khomutov 2023-07-03 03:18:13 +03:00
parent dc7628ed00
commit 9f65f59896
3 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{
"hello": "Hello from KuiToi-Server!",
"config_file": "Use kuitoi.yml for config.",
"config_file": "Use %s for config.",
"debug": "Getting new logging with DEBUG level!",
"config_info": "Server config: %s",
"init": "Initializing ready.",

View File

@ -1,6 +1,6 @@
{
"hello": "Привет из KuiToi-Server!",
"config_file": "Используй kuitoi.yml для настройки.",
"config_file": "Используй %s для настройки.",
"debug": "Начата новая сессия логирования с уровнем DEBUG!",
"config_info": "Конфиг сервера: %s",
"init": "Инициализация окончена.",

View File

@ -9,7 +9,7 @@
import builtins
import json
from core import get_logger
from core.utils import get_logger
class i18n:
@ -25,11 +25,12 @@ class i18n:
class MultiLanguage:
def __init__(self, language: str = None, files_dir="modules/i18n/files/"):
def __init__(self, language: str = None, files_dir="modules/i18n/files/", encoding="utf-8"):
if language is None:
language = "en"
self.__data = {}
self.__i18n = None
self.__encoding = encoding
self.language = language
self.files_dir = files_dir
self.log = get_logger("i18n")
@ -45,7 +46,7 @@ class MultiLanguage:
else:
self.__data = {
"hello": "Hello from KuiToi-Server!",
"config_file": "Use kuitoi.yml for config.",
"config_file": "Use %s for config.",
"debug": "Getting new logging with DEBUG level!",
"config_info": "Server config: %s",
"init": "Initializing ready.",
@ -57,7 +58,7 @@ class MultiLanguage:
self.log.debug("open_file")
file = self.files_dir + self.language + ".json"
try:
with open(file) as f:
with open(file, encoding=self.__encoding) as f:
self.__data.update(json.load(f))
except FileNotFoundError:
self.log.warning(f"Localisation {self.language} not found; Setting language to: en.")