From 48728f0241da56b15f129fd4bcf394ccb01a95b9 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sat, 30 Apr 2022 05:04:15 +1000 Subject: [PATCH] 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). --- imports/locale/shared.lua | 4 ++-- locales/en.json | 5 +++++ locales/fr.json | 5 +++++ resource/locale/client.lua | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 locales/en.json create mode 100644 locales/fr.json diff --git a/imports/locale/shared.lua b/imports/locale/shared.lua index 7937c70..e11190c 100644 --- a/imports/locale/shared.lua +++ b/imports/locale/shared.lua @@ -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 diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..c332031 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,5 @@ +{ + "language": "English", + "ui.close": "Close", + "ui.confirm": "Confirm" +} diff --git a/locales/fr.json b/locales/fr.json new file mode 100644 index 0000000..70abe13 --- /dev/null +++ b/locales/fr.json @@ -0,0 +1,5 @@ +{ + "language": "Français", + "ui.close": "Fermer", + "ui.confirm": "Confirmer" +} diff --git a/resource/locale/client.lua b/resource/locale/client.lua index fa2e53b..07469c9 100644 --- a/resource/locale/client.lua +++ b/resource/locale/client.lua @@ -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