mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2026-04-19 23:00:24 +00:00
Update i18n support
Add new blocks Add docs
This commit is contained in:
@@ -1,8 +1,45 @@
|
||||
{
|
||||
"": "Basic phases",
|
||||
"hello": "Hello from KuiToi-Server!",
|
||||
"config_file": "Use %s for config.",
|
||||
"debug": "Getting new logging with DEBUG level!",
|
||||
"config_info": "Server config: %s",
|
||||
"init": "Initializing ready.",
|
||||
"ready": "Server started!"
|
||||
"config_path": "Use {} for config.",
|
||||
"init_ok": "Initializing ready.",
|
||||
"start": "Server started!",
|
||||
"stop": "Goodbye!",
|
||||
|
||||
"": "Server auth",
|
||||
"auth_need_key": "BEAM key needed for starting the server!",
|
||||
"auth_empty_key": "Key is empty!",
|
||||
"auth_cannot_open_browser": "Cannot open browser: {}",
|
||||
"auth_use_link": "Use this link: {}",
|
||||
|
||||
"": "GUI phases",
|
||||
"GUI_yes": "Yes",
|
||||
"GUI_no": "No",
|
||||
"GUI_ok": "Ok",
|
||||
"GUI_cancel": "Cancel",
|
||||
"GUI_need_key_message": "BEAM key needed for starting the server!\nDo you need to open the web link to obtain the key?",
|
||||
"GUI_enter_key_message": "Please type your key:",
|
||||
"GUI_cannot_open_browser": "Cannot open browser.\nUse this link: {}",
|
||||
|
||||
"": "Command: man",
|
||||
"man_message_man": "man - display the manual page for COMMAND.\nUsage: man COMMAND",
|
||||
"help_message_man": "Display the manual page for COMMAND.",
|
||||
"man_for": "Manual for command",
|
||||
"man_message_not_found": "man: Manual message not found.",
|
||||
"man_command_not_found": "man: command \"{}\" not found!",
|
||||
|
||||
"": "Command: help",
|
||||
"man_message_help": "help - display names and brief descriptions of available commands.\nUsage: help [--raw]\nThe `help` command displays a list of all available commands along with a brief description of each command.",
|
||||
"help_message_help": "Display names and brief descriptions of available commands",
|
||||
"help_command": "Command",
|
||||
"help_message": "Help message",
|
||||
"help_message_not_found": "No help message found",
|
||||
|
||||
"": "Command: stop",
|
||||
"man_message_stop": "stop - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_stop": "Server shutdown.",
|
||||
|
||||
"": "Command: exit",
|
||||
"man_message_exit": "exit - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_exit": "Server shutdown."
|
||||
}
|
||||
@@ -1,10 +1,90 @@
|
||||
class i18n:
|
||||
hello: str = "Hello from KuiToi-Server!"
|
||||
config_file: str = "Use kuitoi.yml for config."
|
||||
debug: str = "Getting new logging with DEBUG level!"
|
||||
config_info: str = "Server config: %s"
|
||||
init: str = "Initializing ready."
|
||||
ready: str = "Server started!"
|
||||
i18n_data = {"hello":"Hello from KuiToi-Server!","config_file":"Use kuitoi.yml for config.",
|
||||
"debug":"Getting new logging with DEBUG level!","config_info":"Server config: %s",
|
||||
"init":"Initializing ready.","ready":"Server started!"}
|
||||
# Basic phases
|
||||
hello: str = data["hello"]
|
||||
config_path: str = data["config_path"]
|
||||
init_ok: str = data["init_ok"]
|
||||
start: str = data["start"]
|
||||
stop: str = data["stop"]
|
||||
|
||||
# Server auth
|
||||
auth_need_key: str = data["auth_need_key"]
|
||||
auth_empty_key: str = data["auth_empty_key"]
|
||||
auth_cannot_open_browser: str = data["auth_cannot_open_browser"]
|
||||
auth_use_link: str = data["auth_use_link"]
|
||||
|
||||
# GUI phases
|
||||
GUI_yes: str = data["GUI_yes"]
|
||||
GUI_no: str = data["GUI_no"]
|
||||
GUI_ok: str = data["GUI_ok"]
|
||||
GUI_cancel: str = data["GUI_cancel"]
|
||||
GUI_need_key_message: str = data["GUI_need_key_message"]
|
||||
GUI_enter_key_message: str = data["GUI_enter_key_message"]
|
||||
GUI_cannot_open_browser: str = data["GUI_cannot_open_browser"]
|
||||
|
||||
# Command: man
|
||||
man_message_man: str = data["man_message_man"]
|
||||
help_message_man: str = data["help_message_man"]
|
||||
man_for: str = data["man_for"]
|
||||
man_message_not_found: str = data["man_message_not_found"]
|
||||
man_command_not_found: str = data["man_command_not_found"]
|
||||
|
||||
# Command: help
|
||||
man_message_help: str = data["man_message_help"]
|
||||
help_message_help: str = data["help_message_help"]
|
||||
help_command: str = data["help_command"]
|
||||
help_message: str = data["help_message"]
|
||||
help_message_not_found: str = data["help_message_not_found"]
|
||||
|
||||
# Command: stop
|
||||
man_message_stop: str = data["man_message_stop"]
|
||||
help_message_stop: str = data["help_message_stop"]
|
||||
|
||||
# Command: exit
|
||||
man_message_exit: str = data["man_message_exit"]
|
||||
help_message_exit: str = data["help_message_exit"]
|
||||
|
||||
data = {
|
||||
"": "Basic phases",
|
||||
"hello": "Hello from KuiToi-Server!",
|
||||
"config_path": "Use {} for config.",
|
||||
"init_ok": "Initializing ready.",
|
||||
"start": "Server started!",
|
||||
"stop": "Goodbye!",
|
||||
|
||||
"": "Server auth",
|
||||
"auth_need_key": "BEAM key needed for starting the server!",
|
||||
"auth_empty_key": "Key is empty!",
|
||||
"auth_cannot_open_browser": "Cannot open browser: {}",
|
||||
"auth_use_link": "Use this link: {}",
|
||||
|
||||
"": "GUI phases",
|
||||
"GUI_yes": "Yes",
|
||||
"GUI_no": "No",
|
||||
"GUI_ok": "Ok",
|
||||
"GUI_cancel": "Cancel",
|
||||
"GUI_need_key_message": "BEAM key needed for starting the server!\nDo you need to open the web link to obtain the key?",
|
||||
"GUI_enter_key_message": "Please type your key:",
|
||||
"GUI_cannot_open_browser": "Cannot open browser.\nUse this link: {}",
|
||||
|
||||
"": "Command: man",
|
||||
"man_message_man": "man - display the manual page for COMMAND.\nUsage: man COMMAND",
|
||||
"help_message_man": "Display the manual page for COMMAND.",
|
||||
"man_for": "Manual for command",
|
||||
"man_message_not_found": "man: Manual message not found.",
|
||||
"man_command_not_found": "man: command \"{}\" not found!",
|
||||
|
||||
"": "Command: help",
|
||||
"man_message_help": "help - display names and brief descriptions of available commands.\nUsage: help [--raw]\nThe `help` command displays a list of all available commands along with a brief description of each command.",
|
||||
"help_message_help": "Display names and brief descriptions of available commands",
|
||||
"help_command": "Command",
|
||||
"help_message": "Help message",
|
||||
"help_message_not_found": "No help message found",
|
||||
|
||||
"": "Command: stop",
|
||||
"man_message_stop": "stop - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_stop": "Server shutdown.",
|
||||
|
||||
"": "Command: exit",
|
||||
"man_message_exit": "exit - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_exit": "Server shutdown."
|
||||
}
|
||||
|
||||
@@ -16,12 +16,51 @@ from core.utils import get_logger
|
||||
class i18n:
|
||||
|
||||
def __init__(self, data):
|
||||
# Basic phases
|
||||
self.hello: str = data["hello"]
|
||||
self.config_file: str = data["config_file"]
|
||||
self.debug: str = data["debug"]
|
||||
self.config_info: str = data["config_info"]
|
||||
self.init: str = data["init"]
|
||||
self.ready: str = data["ready"]
|
||||
self.config_path: str = data["config_path"]
|
||||
self.init_ok: str = data["init_ok"]
|
||||
self.start: str = data["start"]
|
||||
self.stop: str = data["stop"]
|
||||
|
||||
# Server auth
|
||||
self.auth_need_key: str = data["auth_need_key"]
|
||||
self.auth_empty_key: str = data["auth_empty_key"]
|
||||
self.auth_cannot_open_browser: str = data["auth_cannot_open_browser"]
|
||||
self.auth_use_link: str = data["auth_use_link"]
|
||||
|
||||
# GUI phases
|
||||
self.GUI_yes: str = data["GUI_yes"]
|
||||
self.GUI_no: str = data["GUI_no"]
|
||||
self.GUI_ok: str = data["GUI_ok"]
|
||||
self.GUI_cancel: str = data["GUI_cancel"]
|
||||
self.GUI_need_key_message: str = data["GUI_need_key_message"]
|
||||
self.GUI_enter_key_message: str = data["GUI_enter_key_message"]
|
||||
self.GUI_cannot_open_browser: str = data["GUI_cannot_open_browser"]
|
||||
|
||||
# Command: man
|
||||
self.man_message_man: str = data["man_message_man"]
|
||||
self.help_message_man: str = data["help_message_man"]
|
||||
self.man_for: str = data["man_for"]
|
||||
self.man_message_not_found: str = data["man_message_not_found"]
|
||||
self.man_command_not_found: str = data["man_command_not_found"]
|
||||
|
||||
# Command: help
|
||||
self.man_message_help: str = data["man_message_help"]
|
||||
self.help_message_help: str = data["help_message_help"]
|
||||
self.help_command: str = data["help_command"]
|
||||
self.help_message: str = data["help_message"]
|
||||
self.help_message_not_found: str = data["help_message_not_found"]
|
||||
|
||||
# Command: help
|
||||
self.man_message_stop: str = data["man_message_stop"]
|
||||
self.help_message_stop: str = data["help_message_stop"]
|
||||
|
||||
# Command: exit
|
||||
self.man_message_exit: str = data["man_message_exit"]
|
||||
self.help_message_exit: str = data["help_message_exit"]
|
||||
|
||||
self.data = data
|
||||
|
||||
|
||||
class MultiLanguage:
|
||||
@@ -45,13 +84,51 @@ class MultiLanguage:
|
||||
if language != "en":
|
||||
self.open_file()
|
||||
else:
|
||||
# noinspection PyDictDuplicateKeys
|
||||
self.__data = {
|
||||
"": "Basic phases",
|
||||
"hello": "Hello from KuiToi-Server!",
|
||||
"config_file": "Use %s for config.",
|
||||
"debug": "Getting new logging with DEBUG level!",
|
||||
"config_info": "Server config: %s",
|
||||
"init": "Initializing ready.",
|
||||
"ready": "Server started!"
|
||||
"config_path": "Use {} for config.",
|
||||
"init_ok": "Initializing ready.",
|
||||
"start": "Server started!",
|
||||
"stop": "Goodbye!",
|
||||
|
||||
"": "Server auth",
|
||||
"auth_need_key": "BEAM key needed for starting the server!",
|
||||
"auth_empty_key": "Key is empty!",
|
||||
"auth_cannot_open_browser": "Cannot open browser: {}",
|
||||
"auth_use_link": "Use this link: {}",
|
||||
|
||||
"": "GUI phases",
|
||||
"GUI_yes": "Yes",
|
||||
"GUI_no": "No",
|
||||
"GUI_ok": "Ok",
|
||||
"GUI_cancel": "Cancel",
|
||||
"GUI_need_key_message": "BEAM key needed for starting the server!\nDo you need to open the web link to obtain the key?",
|
||||
"GUI_enter_key_message": "Please type your key:",
|
||||
"GUI_cannot_open_browser": "Cannot open browser.\nUse this link: {}",
|
||||
|
||||
"": "Command: man",
|
||||
"man_message_man": "man - display the manual page for COMMAND.\nUsage: man COMMAND",
|
||||
"help_message_man": "Display the manual page for COMMAND.",
|
||||
"man_for": "Manual for command",
|
||||
"man_message_not_found": "man: Manual message not found.",
|
||||
"man_command_not_found": "man: command \"{}\" not found!",
|
||||
|
||||
"": "Command: help",
|
||||
"man_message_help": "help - display names and brief descriptions of available commands.\nUsage: help [--raw]\nThe `help` command displays a list of all available commands along with a brief description of each command.",
|
||||
"help_message_help": "Display names and brief descriptions of available commands",
|
||||
"help_command": "Command",
|
||||
"help_message": "Help message",
|
||||
"help_message_not_found": "No help message found",
|
||||
|
||||
"": "Command: stop",
|
||||
"man_message_stop": "stop - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_stop": "Server shutdown.",
|
||||
|
||||
"": "Command: exit",
|
||||
"man_message_exit": "exit - Just shutting down the server.\nUsage: stop",
|
||||
"help_message_exit": "Server shutdown."
|
||||
}
|
||||
self.__i18n = i18n(self.__data)
|
||||
|
||||
@@ -63,7 +140,8 @@ class MultiLanguage:
|
||||
self.__data.update(json.load(f))
|
||||
return
|
||||
except JSONDecodeError:
|
||||
self.log.error(f"Localisation \"{self.language}.json\" have JsonDecodeError. Using default localisation: en.")
|
||||
self.log.error(
|
||||
f"Localisation \"{self.language}.json\" have JsonDecodeError. Using default localisation: en.")
|
||||
except FileNotFoundError:
|
||||
self.log.warning(f"Localisation \"{self.language}.json\" not found; Using default localisation: en.")
|
||||
self.set_language("en")
|
||||
|
||||
Reference in New Issue
Block a user