handle nil given parameter in Translate function

This commit is contained in:
Horváth Gellért
2023-04-22 16:00:11 +02:00
parent fca0756c65
commit e102fc7cea
+5
View File
@@ -1,6 +1,11 @@
Locales = {}
function Translate(str, ...) -- Translate string
if not str then
local currentResourceName = GetCurrentResourceName()
print(("[^1ERROR^7] Resource ^5%s^7 You did not specify a parameter for the Translate function or the value is nil!"):format(currentResourceName))
return 'Given translate function parameter is nil!'
end
if Locales[Config.Locale] then
if Locales[Config.Locale][str] then
return string.format(Locales[Config.Locale][str], ...)