-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtranslationUtils.lua
More file actions
25 lines (23 loc) · 892 Bytes
/
translationUtils.lua
File metadata and controls
25 lines (23 loc) · 892 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
25
--[[
name: translationUtils.lua
description: Contains translate() which formats strings and checks for available language
]]--
do
function translate(playerName, what, ...)
-- if we don't have this string translated, use english
local language
if playerName == nil then
language = translations.en
elseif string.sub(playerName, 1, 1) ~= "*" and string.find(playerName, "#") == nil then
language = translations[playerName] or translations.en
else
language = playerVars[playerName].playerLanguage or translations.en
end
local translated = language[what] or translations.en[what]
assert(translated, "'"..what.."' is an invalid argument.")
if select("#", ...) > 0 then
return string.format(translated, ...)
end
return translated
end
end