Fix locale

This commit is contained in:
Lorraxs 2024-04-09 16:37:30 +07:00
parent 481d82d612
commit cff9c609c6
6 changed files with 26 additions and 19 deletions

View File

@ -1,4 +1,3 @@
Locales = {}
Config = {} Config = {}
Config.Dependencies = {} -- Reqired resources loaded to start Config.Dependencies = {} -- Reqired resources loaded to start

View File

@ -28,8 +28,9 @@ ui_page 'web/build/index.html'
shared_scripts { shared_scripts {
'@ox_lib/init.lua', '@ox_lib/init.lua',
"locales/L.lua",
"locales/lang/*.lua",
"config.lua", "config.lua",
"locales/*.lua",
"main.lua", "main.lua",
"impl.lua", "impl.lua",
} }

15
locales/L.lua Normal file
View File

@ -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

View File

@ -1,3 +0,0 @@
Locales['default'] = {
['TEST'] = "Test"
}

9
locales/lang/default.lua Normal file
View File

@ -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")

View File

@ -411,17 +411,3 @@ Citizen.CreateThread(function()
end end
main:InitImplAfterPlayerLoaded() main:InitImplAfterPlayerLoaded()
end) 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