forked from nonamerpcz/es_extended
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocale.lua
More file actions
43 lines (32 loc) · 1.16 KB
/
locale.lua
File metadata and controls
43 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- Copyright (c) Jérémie N'gadi
--
-- All rights reserved.
--
-- Even if 'All rights reserved' is very clear :
--
-- You shall not use any piece of this software in a commercial product / service
-- You shall not resell this software
-- You shall not provide any facility to install this particular software in a commercial product / service
-- If you redistribute this software, you must link to ORIGINAL repository at https://github.com/ESX-Org/es_extended
-- This copyright should appear in every part of the project code
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
return 'Locale [' .. Config.Locale .. '] does not exist'
end
end
function _U(str, ...) -- Translate string first char uppercase
return tostring(_(str, ...):gsub("^%l", string.upper))
end
function LoadLocale(ns, lang, data)
Locales[lang] = Locales[lang] or {}
for k,v in pairs(data) do
Locales[lang][ns .. ':' .. k] =v
end
end