-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalization.lua
More file actions
16 lines (15 loc) · 790 Bytes
/
Copy pathLocalization.lua
File metadata and controls
16 lines (15 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- Translate addon-owned presentation only. Received event facts may be rendered
-- locally; identifiers, original wire text and native data remain unchanged.
local _, namespace = ...
namespace.localizations = {}
local aliases = { enGB = "enUS" }
local ok, locale = pcall(function() return GetLocale and GetLocale() or "enUS" end)
namespace.locale = ok and type(locale) == "string" and (aliases[locale] or locale) or "enUS"
function namespace.TranslateForLocale(text, selected)
if type(text) ~= "string" then return text end
local dictionary = namespace.localizations[aliases[selected] or selected]
return dictionary and dictionary[text] or text
end
function namespace.Translate(text)
return namespace.TranslateForLocale(text, namespace.localizationTestLocale or namespace.locale)
end