From dffaa5caae3e8e77c2252675aaa7ba2482c1d7d8 Mon Sep 17 00:00:00 2001 From: Csoki Date: Thu, 15 Sep 2022 00:24:55 +0200 Subject: [PATCH] refactor translate function --- [esx]/es_extended/locale.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/[esx]/es_extended/locale.lua b/[esx]/es_extended/locale.lua index 68de6651..04482bea 100644 --- a/[esx]/es_extended/locale.lua +++ b/[esx]/es_extended/locale.lua @@ -1,19 +1,15 @@ Locales = {} function _(str, ...) -- Translate string - - if Locales[Config.Locale] ~= nil then - - if Locales[Config.Locale][str] ~= nil then - return string.format(Locales[Config.Locale][str], ...) - else - return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist' - end - - else + if not Locales[Config.Locale] then return 'Locale [' .. Config.Locale .. '] does not exist' end + if Locales[Config.Locale][str] then + return string.format(Locales[Config.Locale][str], ...) + end + + return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist' end function _U(str, ...) -- Translate string first char uppercase