mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(locales): include some locales
Partial, and google translated just for the sake of setting an example. Also renamed many of the language codes where the extra characters are redundant (i.e. fr-FR, de-DE).
This commit is contained in:
@@ -16,7 +16,7 @@ end
|
||||
|
||||
local function loadLocale(locale)
|
||||
local resourceName = GetCurrentResourceName()
|
||||
local JSON = LoadResourceFile(resourceName, ('locales/%s.json'):format(locale)) or LoadResourceFile(resourceName, ('locales/en-US.json'):format(locale))
|
||||
local JSON = LoadResourceFile(resourceName, ('locales/%s.json'):format(locale)) or LoadResourceFile(resourceName, ('locales/en.json'):format(locale))
|
||||
|
||||
if JSON then
|
||||
dict = json.decode(JSON)
|
||||
@@ -26,6 +26,6 @@ end
|
||||
AddEventHandler('ox_lib:setLocale', loadLocale)
|
||||
|
||||
return function()
|
||||
local lang = IsDuplicityVersion() and lib.getServerLocale() or GetExternalKvpString('ox_lib', 'locale') or 'en-US'
|
||||
local lang = IsDuplicityVersion() and lib.getServerLocale() or GetExternalKvpString('ox_lib', 'locale') or 'en'
|
||||
loadLocale(lang)
|
||||
end
|
||||
|
||||
5
locales/en.json
Normal file
5
locales/en.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"language": "English",
|
||||
"ui.close": "Close",
|
||||
"ui.confirm": "Confirm"
|
||||
}
|
||||
5
locales/fr.json
Normal file
5
locales/fr.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"language": "Français",
|
||||
"ui.close": "Fermer",
|
||||
"ui.confirm": "Confirmer"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
local userLocale = GetResourceKvpString('locale')
|
||||
|
||||
local function loadLocale(locale, cb)
|
||||
local JSON = LoadResourceFile('ox_lib', ('locales/%s.json'):format(locale)) or LoadResourceFile('ox_lib', ('locales/en-US.json'):format(locale))
|
||||
local JSON = LoadResourceFile('ox_lib', ('locales/%s.json'):format(locale)) or LoadResourceFile('ox_lib', ('locales/en.json'):format(locale))
|
||||
if cb then cb(JSON) end
|
||||
|
||||
SetResourceKvp('locale', locale)
|
||||
@@ -11,7 +11,7 @@ end
|
||||
RegisterNUICallback('getLocale', loadLocale)
|
||||
|
||||
if not userLocale then
|
||||
local default = { 'en-US', 'fr-FR', 'de-DE', 'it-IT', 'es-ES', 'pt-BR', 'pl-PL', 'ru-RU', 'ko-KR', 'zh-TW', 'ja-JP', 'es-MX', 'zh-CN' }
|
||||
local default = { 'en', 'fr', 'de', 'it', 'es', 'pt-BR', 'pl', 'ru', 'ko', 'zh-TW', 'ja', 'es-MX', 'zh-CN' }
|
||||
userLocale = default[GetCurrentLanguage() + 1]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user