Added Plugins loaders translations.

This commit is contained in:
2023-07-26 04:28:57 +03:00
parent 9295ed2b7a
commit 21dd23cb55
6 changed files with 89 additions and 15 deletions

View File

@@ -580,13 +580,10 @@ class LuaPluginsLoader:
def load(self):
self.log.debug("Loading Lua plugins...")
# TODO: i18n
self.log.info("You have enabled support for Lua plugins.")
self.log.warning("There are some nuances to working with KuiToi. "
"If you have a proposal for their solution, and it is related to KuiToi, "
"please contact the developer.")
self.log.warning("Some BeamMP plugins require a correctly configured ServerConfig.toml file to function.")
self.log.info("Creating it.")
self.log.info(i18n.plugins_lua_enabled)
self.log.warning(i18n.plugins_lua_nuances_warning)
self.log.warning(i18n.plugins_lua_legacy_config_create_warning)
self.log.info(i18n.plugins_lua_legacy_config_create)
data = {
"info": "ServerConfig.toml is created solely for backward compatibility support. "
"This file will be updated every time the program is launched.",
@@ -674,6 +671,6 @@ class LuaPluginsLoader:
self.log.debug("Unloading lua plugins")
for name, data in self.lua_plugins.items():
if data['ok']:
self.log.info(f"Unloading lua plugin: {name}")
self.log.info(i18n.plugins_lua_unload.format(name))
for _, timer in data['lua'].globals().MP._event_timers.items():
timer.stop()

View File

@@ -131,21 +131,21 @@ class PluginsLoader:
try:
is_func = inspect.isfunction
if not is_func(plugin.load):
self.log.error('Function "def load():" not found.')
self.log.error(i18n.plugins_not_found_load)
ok = False
if not is_func(plugin.start):
self.log.error('Function "def start():" not found.')
self.log.error(i18n.plugins_not_found_start)
ok = False
if not is_func(plugin.unload):
self.log.error('Function "def unload():" not found.')
self.log.error(i18n.plugins_not_found_unload)
ok = False
if type(plugin.kt) != KuiToi:
self.log.error(f'Attribute "kt" isn\'t KuiToi class. Plugin file: "{file_path}"')
self.log.error(i18n.plugins_kt_invalid)
ok = False
except AttributeError:
ok = False
if not ok:
self.log.error(f'Plugin file: "{file_path}" is not a valid KuiToi plugin.')
self.log.error(i18n.plugins_invalid.format(file_path))
return
pl_name = plugin.kt.name
@@ -185,9 +185,8 @@ class PluginsLoader:
self.loaded_str += f"{pl_name}:ok, "
self.log.debug(f"Plugin loaded: {file}. Settings: {self.plugins[pl_name]}")
except Exception as e:
# TODO: i18n
self.loaded_str += f"{file}:no, "
self.log.error(f"Error while loading plugin: {file}; Error: {e}")
self.log.error(i18n.plugins_error_loading.format(file, f"{e}"))
self.log.exception(e)
async def start(self, _):