From cff9c609c64d30a93f1fa20ac9053356026c8d3b Mon Sep 17 00:00:00 2001 From: Lorraxs Date: Tue, 9 Apr 2024 16:37:30 +0700 Subject: [PATCH] Fix locale --- config.lua | 1 - fxmanifest.lua | 3 ++- locales/L.lua | 15 +++++++++++++++ locales/default.lua | 3 --- locales/lang/default.lua | 9 +++++++++ main.lua | 14 -------------- 6 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 locales/L.lua delete mode 100644 locales/default.lua create mode 100644 locales/lang/default.lua diff --git a/config.lua b/config.lua index a490a6b..224c415 100644 --- a/config.lua +++ b/config.lua @@ -1,4 +1,3 @@ -Locales = {} Config = {} Config.Dependencies = {} -- Reqired resources loaded to start diff --git a/fxmanifest.lua b/fxmanifest.lua index 4412cb0..452ce15 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -28,8 +28,9 @@ ui_page 'web/build/index.html' shared_scripts { '@ox_lib/init.lua', + "locales/L.lua", + "locales/lang/*.lua", "config.lua", - "locales/*.lua", "main.lua", "impl.lua", } diff --git a/locales/L.lua b/locales/L.lua new file mode 100644 index 0000000..85205b3 --- /dev/null +++ b/locales/L.lua @@ -0,0 +1,15 @@ +Locales = {} + +function L(key, args) + if not args then args = {} end + if type(args) ~= "table" then args = {} end + if Config.Settings.locale[key] then + local pattern = Config.Settings.locale[key] + for k, v in pairs(args) do + pattern = pattern:gsub(":{" .. k .. "}", v) + end + return pattern + else + return key + end +end diff --git a/locales/default.lua b/locales/default.lua deleted file mode 100644 index 93908aa..0000000 --- a/locales/default.lua +++ /dev/null @@ -1,3 +0,0 @@ -Locales['default'] = { - ['TEST'] = "Test" -} diff --git a/locales/lang/default.lua b/locales/lang/default.lua new file mode 100644 index 0000000..98b2073 --- /dev/null +++ b/locales/lang/default.lua @@ -0,0 +1,9 @@ +Locales['default'] = { + ['KILLED YOU'] = "ĐÃ HẠ BẠN", + ['KILLED BY'] = "BỊ HẠ GỤC BỞI", + ['OUTGOING'] = "GÂY RA", + ['COMBAT REPORT'] = "BÁO CÁO GIAO TRANH", + ['INCOMING'] = "NHẬN VÀO", +} + +print("Ádasd") diff --git a/main.lua b/main.lua index b11e341..cee9762 100644 --- a/main.lua +++ b/main.lua @@ -411,17 +411,3 @@ Citizen.CreateThread(function() end main:InitImplAfterPlayerLoaded() end) - -function L(key, args) - if not args then args = {} end - if type(args) ~= "table" then args = {} end - if Config.Settings.locale[key] then - local pattern = Config.Settings.locale[key] - for k, v in pairs(args) do - pattern = pattern:gsub(":{" .. k .. "}", v) - end - return pattern - else - return key - end -end