mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-17 08:15:42 +00:00
Final of i18n
This commit is contained in:
parent
719e705bab
commit
cdeacc16bf
@ -56,12 +56,12 @@ class EventsSystem:
|
|||||||
"onInit": [], # onServerStarted
|
"onInit": [], # onServerStarted
|
||||||
"onShutdown": [], # onServerStopped
|
"onShutdown": [], # onServerStopped
|
||||||
"onPlayerAuth": [], # onPlayerAuthenticated
|
"onPlayerAuth": [], # onPlayerAuthenticated
|
||||||
"onPlayerConnecting": [], # TODO lua onPlayerConnecting
|
"onPlayerConnecting": [], # No
|
||||||
"onPlayerJoining": [], # TODO lua onPlayerJoining
|
"onPlayerJoining": [], # No
|
||||||
"onPlayerJoin": [], # onPlayerJoin
|
"onPlayerJoin": [], # onPlayerJoin
|
||||||
"onPlayerDisconnect": [], # TODO lua onPlayerDisconnect
|
"onPlayerDisconnect": [], # onPlayerDisconnect
|
||||||
"onChatMessage": [], # onChatReceive
|
"onChatMessage": [], # onChatReceive
|
||||||
"onVehicleSpawn": [], # "onCarSpawn
|
"onVehicleSpawn": [], # onCarSpawn
|
||||||
"onVehicleEdited": [], # onCarEdited
|
"onVehicleEdited": [], # onCarEdited
|
||||||
"onVehicleDeleted": [], # onCarDelete
|
"onVehicleDeleted": [], # onCarDelete
|
||||||
"onVehicleReset": [], # onCarReset
|
"onVehicleReset": [], # onCarReset
|
||||||
@ -85,9 +85,7 @@ class EventsSystem:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if not callable(event_func):
|
if not callable(event_func):
|
||||||
# TODO: i18n
|
self.log.error(i18n.events_not_callable.format(event_name, f"kt.add_event(\"{event_name}\", function)"))
|
||||||
self.log.error(f"Cannot add event '{event_name}'. "
|
|
||||||
f"Use `KuiToi.add_event({event_name}', function)` instead. Skipping it...")
|
|
||||||
return
|
return
|
||||||
if async_event or inspect.iscoroutinefunction(event_func):
|
if async_event or inspect.iscoroutinefunction(event_func):
|
||||||
if event_name not in self.__async_events:
|
if event_name not in self.__async_events:
|
||||||
@ -112,12 +110,10 @@ class EventsSystem:
|
|||||||
data = await func(event_data)
|
data = await func(event_data)
|
||||||
funcs_data.append(data)
|
funcs_data.append(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: i18n
|
self.log.error(i18n.events_calling_error.format(event_name, func.__name__))
|
||||||
self.log.error(f'Error while calling "{event_name}"; In function: "{func.__name__}"')
|
|
||||||
self.log.exception(e)
|
self.log.exception(e)
|
||||||
else:
|
else:
|
||||||
# TODO: i18n
|
self.log.warning(i18n.events_not_found.format(event_name, "kt.call_event()"))
|
||||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_event()?. Just skipping it...")
|
|
||||||
|
|
||||||
return funcs_data
|
return funcs_data
|
||||||
|
|
||||||
@ -132,12 +128,10 @@ class EventsSystem:
|
|||||||
event_data = {"event_name": event_name, "args": args, "kwargs": kwargs}
|
event_data = {"event_name": event_name, "args": args, "kwargs": kwargs}
|
||||||
funcs_data.append(func(event_data))
|
funcs_data.append(func(event_data))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: i18n
|
self.log.error(i18n.events_calling_error.format(event_name, func.__name__))
|
||||||
self.log.error(f'Error while calling "{event_name}"; In function: "{func.__name__}"')
|
|
||||||
self.log.exception(e)
|
self.log.exception(e)
|
||||||
else:
|
else:
|
||||||
# TODO: i18n
|
self.log.warning(i18n.events_not_found.format(event_name, "kt.call_async_event()"))
|
||||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_async_event()?. Just skipping it...")
|
|
||||||
|
|
||||||
return funcs_data
|
return funcs_data
|
||||||
|
|
||||||
@ -151,21 +145,13 @@ class EventsSystem:
|
|||||||
try:
|
try:
|
||||||
func = lua.globals()[func_name]
|
func = lua.globals()[func_name]
|
||||||
if not func:
|
if not func:
|
||||||
self.log.warning(f"Cannot trigger local event: '{func_name}' not found!")
|
self.log.warning(i18n.events_lua_function_not_found.format("", func_name))
|
||||||
continue
|
continue
|
||||||
fd = func(*args)
|
fd = func(*args)
|
||||||
funcs_data.append(fd)
|
funcs_data.append(fd)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: i18n
|
self.log.error(i18n.events_lua_calling_error.format(f"{e}", event_name, func_name, f"{args}"))
|
||||||
self.log.error(f'Error: "{e}" - while calling lua event "{event_name}" with arguments: {args} - '
|
|
||||||
f'in function: "{func_name}"')
|
|
||||||
# self.log.exception(e)
|
|
||||||
else:
|
else:
|
||||||
# TODO: i18n
|
self.log.warning(i18n.events_not_found.format(event_name, "ev.call_lua_event(), MP.Trigger<>Event()"))
|
||||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_lua_event() or MP.Trigger<>Event()?. "
|
|
||||||
f"Just skipping it...")
|
|
||||||
|
|
||||||
return funcs_data
|
return funcs_data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class EventTimer:
|
|||||||
self.mp.TriggerLocalEvent(self.event_name)
|
self.mp.TriggerLocalEvent(self.event_name)
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming,PyProtectedMember
|
||||||
class MP:
|
class MP:
|
||||||
|
|
||||||
def __init__(self, name: str, lua: LuaRuntime):
|
def __init__(self, name: str, lua: LuaRuntime):
|
||||||
@ -117,19 +117,15 @@ class MP:
|
|||||||
try:
|
try:
|
||||||
func = self._lua.globals()[func_name]
|
func = self._lua.globals()[func_name]
|
||||||
if not func:
|
if not func:
|
||||||
self.log.warning(f"Cannot trigger local event: '{func_name}' not found!")
|
self.log.warning(i18n.events_lua_function_not_found.format(i18n.events_lua_local, func_name))
|
||||||
continue
|
continue
|
||||||
fd = func(*args)
|
fd = func(*args)
|
||||||
funcs_data.append(fd)
|
funcs_data.append(fd)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: i18n
|
self.log.error(i18n.events_lua_calling_error.format(f"{e}", event_name, func_name, f"{args}"))
|
||||||
self.log.error(f'Error: "{e}" - while calling lua event "{event_name}" with arguments: {args} - '
|
|
||||||
f'in function: "{func_name}"')
|
|
||||||
# self.log.exception(e)
|
|
||||||
else:
|
else:
|
||||||
# TODO: i18n
|
self.log.warning(i18n.events_not_found.format(event_name, "ev.call_lua_event(), MP.Trigger<>Event()"))
|
||||||
self.log.warning(f"Event {event_name} does not exist, maybe ev.call_lua_event() or MP.Trigger<>Event()?. "
|
|
||||||
f"Just skipping it...")
|
|
||||||
|
|
||||||
return self._lua.table_from(funcs_data)
|
return self._lua.table_from(funcs_data)
|
||||||
|
|
||||||
@ -563,6 +559,7 @@ class FS:
|
|||||||
return os.path.join(*args)
|
return os.path.join(*args)
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyProtectedMember
|
||||||
class LuaPluginsLoader:
|
class LuaPluginsLoader:
|
||||||
|
|
||||||
def __init__(self, plugins_dir):
|
def __init__(self, plugins_dir):
|
||||||
|
@ -57,7 +57,14 @@
|
|||||||
"client_event_invalid_data": "从事件返回的数据无效:{}",
|
"client_event_invalid_data": "从事件返回的数据无效:{}",
|
||||||
"client_player_disconnected": "离开服务器。游戏时间:{}分钟。",
|
"client_player_disconnected": "离开服务器。游戏时间:{}分钟。",
|
||||||
|
|
||||||
"": "Events system",
|
"": "事件系统",
|
||||||
|
|
||||||
|
"events_not_callable": "无法添加事件\"{}\"。请改用\"{}\"。跳过...",
|
||||||
|
"events_not_found": "事件\"{}\"未注册。也许{}?跳过...",
|
||||||
|
"events_calling_error": "调用函数\"{}\"时出错。",
|
||||||
|
"events_lua_function_not_found": "无法调用{}lua事件 - 未找到\"{}\"。",
|
||||||
|
"events_lua_local": "本地 ",
|
||||||
|
"events_lua_calling_error": "错误:\"{}\" - 调用lua事件\"{}\"时出错,函数:\"{}\",参数:{}",
|
||||||
|
|
||||||
"": "插件加载器",
|
"": "插件加载器",
|
||||||
|
|
||||||
|
@ -59,6 +59,13 @@
|
|||||||
|
|
||||||
"": "Events system",
|
"": "Events system",
|
||||||
|
|
||||||
|
"events_not_callable": "Unable to add event \"{}\". Use \"{}\" instead. Skipping...",
|
||||||
|
"events_not_found": "Event \"{}\" is not registered. Maybe {}? Skipping...",
|
||||||
|
"events_calling_error": "Error calling \"{}\" in function \"{}\".",
|
||||||
|
"events_lua_function_not_found": "Unable to call {}lua event - \"{}\" not found.",
|
||||||
|
"events_lua_local": "local ",
|
||||||
|
"events_lua_calling_error": "Error: \"{}\" - calling lua event \"{}\", function: \"{}\", arguments: {}",
|
||||||
|
|
||||||
"": "Plugins loader",
|
"": "Plugins loader",
|
||||||
|
|
||||||
"plugins_not_found_load": "Function \"def load():\" not found.",
|
"plugins_not_found_load": "Function \"def load():\" not found.",
|
||||||
|
@ -59,6 +59,13 @@
|
|||||||
|
|
||||||
"": "Events system",
|
"": "Events system",
|
||||||
|
|
||||||
|
"events_not_callable": "Невозможно добавить ивент \"{}\". Использую лучше \"{}\". Скип...",
|
||||||
|
"events_not_found": "Ивент \"{}\" не зарегистрирован. Может {}? Скип...",
|
||||||
|
"events_calling_error": "Ошибка во время вызова \"{}\" в функции \"{}\".",
|
||||||
|
"events_lua_function_not_found": "Невозможно вызвать {}lua ивент - \"{}\" не найдена.",
|
||||||
|
"events_lua_local": "локальный ",
|
||||||
|
"events_lua_calling_error": "Ошибка: \"{}\" - во время вызова lua ивента \"{}\", функция: \"{}\" , аргументы: {}",
|
||||||
|
|
||||||
"": "Plugins loader",
|
"": "Plugins loader",
|
||||||
|
|
||||||
"plugins_not_found_load": "Функция \"def load():\" не найдена.",
|
"plugins_not_found_load": "Функция \"def load():\" не найдена.",
|
||||||
|
@ -62,7 +62,12 @@ class i18n:
|
|||||||
|
|
||||||
# Events system
|
# Events system
|
||||||
|
|
||||||
|
events_not_callable: str
|
||||||
|
events_not_found: str
|
||||||
|
events_calling_error: str
|
||||||
|
events_lua_function_not_found: str
|
||||||
|
events_lua_local: str
|
||||||
|
events_lua_calling_error: str
|
||||||
|
|
||||||
# Plugins loader
|
# Plugins loader
|
||||||
|
|
||||||
|
@ -106,6 +106,32 @@ class MultiLanguage:
|
|||||||
"client_event_invalid_data": "Invalid data returned from event: {}",
|
"client_event_invalid_data": "Invalid data returned from event: {}",
|
||||||
"client_player_disconnected": "Left the server. Playtime: {} min",
|
"client_player_disconnected": "Left the server. Playtime: {} min",
|
||||||
|
|
||||||
|
"": "Events system",
|
||||||
|
|
||||||
|
"events_not_callable": "Unable to add event \"{}\". Use \"{}\" instead. Skipping...",
|
||||||
|
"events_not_found": "Event \"{}\" is not registered. Maybe {}? Skipping...",
|
||||||
|
"events_calling_error": "Error calling \"{}\" in function \"{}\".",
|
||||||
|
"events_lua_function_not_found": "Unable to call {}lua event - \"{}\" not found.",
|
||||||
|
"events_lua_local": "local ",
|
||||||
|
"events_lua_calling_error": "Error: \"{}\" - calling lua event \"{}\", function: \"{}\", arguments: {}",
|
||||||
|
|
||||||
|
"": "Plugins loader",
|
||||||
|
|
||||||
|
"plugins_not_found_load": "Function \"def load():\" not found.",
|
||||||
|
"plugins_not_found_start": "Function \"def start():\" not found.",
|
||||||
|
"plugins_not_found_unload": "Function \"def unload():\" not found.",
|
||||||
|
"plugins_kt_invalid": "\"kt\" variable does not belong to the KuiToi class.",
|
||||||
|
"plugins_invalid": "Plugin \"{}\" cannot be run in KuiToi.",
|
||||||
|
"plugins_error_loading": "An error occurred while loading the plugin {}: {}",
|
||||||
|
|
||||||
|
"": "Lua plugins loader",
|
||||||
|
|
||||||
|
"plugins_lua_enabled": "You have enabled Lua plugin support.",
|
||||||
|
"plugins_lua_nuances_warning": "There are some nuances when working with Kuiti. If you have a suggestion for their solution, and it is related to KuiToi, please contact the developer.",
|
||||||
|
"plugins_lua_legacy_config_create_warning": "Some BeamMP plugins require a properly configured ServerConfig.toml file to function.",
|
||||||
|
"plugins_lua_legacy_config_create": "Creating it.",
|
||||||
|
"plugins_lua_unload": "Stopping Lua plugin: {}",
|
||||||
|
|
||||||
"": "Command: man",
|
"": "Command: man",
|
||||||
"man_message_man": "man - Shows the help page for COMMAND.\nUsage: man COMMAND",
|
"man_message_man": "man - Shows the help page for COMMAND.\nUsage: man COMMAND",
|
||||||
"help_message_man": "Shows the help page for COMMAND.",
|
"help_message_man": "Shows the help page for COMMAND.",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user