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
|
working-directory: ./web
|
||||||
run: yarn build
|
run: yarn build
|
||||||
- name: Zip Folder
|
- 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'
|
- uses: 'marvinpinto/action-automatic-releases@latest'
|
||||||
with:
|
with:
|
||||||
repo_token: '${{ secrets.GITHUB_TOKEN }}'
|
repo_token: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
Locales = {}
|
||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
Config.Dependencies = {} -- Reqired resources loaded to start
|
Config.Dependencies = {} -- Reqired resources loaded to start
|
||||||
|
Config.Locale = 'vi'
|
||||||
|
|
||||||
Config.Settings = {
|
Config.Settings = {
|
||||||
locale = {}
|
locale = Locales[Config.Locale] or Locales['default']
|
||||||
}
|
}
|
||||||
|
|
||||||
--Dont touch this
|
--Dont touch this
|
||||||
|
|
|
@ -29,6 +29,7 @@ ui_page 'web/build/index.html'
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'@ox_lib/init.lua',
|
'@ox_lib/init.lua',
|
||||||
"config.lua",
|
"config.lua",
|
||||||
|
"locales/*.lua",
|
||||||
"main.lua",
|
"main.lua",
|
||||||
"impl.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
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user