Add locales system
This commit is contained in:
parent
78bf2c1c3f
commit
481d82d612
2
.github/workflows/autorelease.yml
vendored
2
.github/workflows/autorelease.yml
vendored
|
@ -27,7 +27,7 @@ jobs:
|
|||
working-directory: ./web
|
||||
run: yarn build
|
||||
- name: Zip Folder
|
||||
run: zip -r ${{ github.event.repository.name }}.zip config.lua fxmanifest.lua impl.lua main.lua README.md LICENSE web/build/* client/* server/*
|
||||
run: zip -r ${{ github.event.repository.name }}.zip config.lua fxmanifest.lua impl.lua main.lua README.md LICENSE web/build/* locales/* client/* server/*
|
||||
- uses: 'marvinpinto/action-automatic-releases@latest'
|
||||
with:
|
||||
repo_token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
Locales = {}
|
||||
Config = {}
|
||||
|
||||
Config.Dependencies = {} -- Reqired resources loaded to start
|
||||
Config.Locale = 'vi'
|
||||
|
||||
Config.Settings = {
|
||||
locale = {}
|
||||
locale = Locales[Config.Locale] or Locales['default']
|
||||
}
|
||||
|
||||
--Dont touch this
|
||||
|
|
|
@ -29,6 +29,7 @@ ui_page 'web/build/index.html'
|
|||
shared_scripts {
|
||||
'@ox_lib/init.lua',
|
||||
"config.lua",
|
||||
"locales/*.lua",
|
||||
"main.lua",
|
||||
"impl.lua",
|
||||
}
|
||||
|
|
3
locales/default.lua
Normal file
3
locales/default.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
Locales['default'] = {
|
||||
['TEST'] = "Test"
|
||||
}
|
14
main.lua
14
main.lua
|
@ -411,3 +411,17 @@ 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user