-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlocale.lua
More file actions
24 lines (21 loc) · 767 Bytes
/
locale.lua
File metadata and controls
24 lines (21 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Locales = {}
function Translate(str, ...) -- Translate string
if Locales[Config.Locale] then
if Locales[Config.Locale][str] then
return string.format(Locales[Config.Locale][str], ...)
elseif Config.Locale ~= 'en' and Locales['en'] and Locales['en'][str] then
return string.format(Locales['en'][str], ...)
else
return 'Translation [' .. Config.Locale .. '][' .. str .. '] does not exist'
end
elseif Config.Locale ~= 'en' and Locales['en'] and Locales['en'][str] then
return string.format(Locales['en'][str], ...)
else
return 'Locale [' .. Config.Locale .. '] does not exist'
end
end
function TranslateCap(str, ...) -- Translate string first char uppercase
return _(str, ...):gsub("^%l", string.upper)
end
_ = Translate
_U = TranslateCap