core: use local variable to check for translations

Some old addons (e.g. ArcHUD2) populate a "T" variable in global space which
made pfUI/ShaguPlates assume the translations would have already been loaded
and further loading has been stopped by this. Now using a local variable as
flag to determine if translations where actually processed or not.
This commit is contained in:
shagu
2021-02-11 11:00:09 +01:00
parent 7a33a57e39
commit 2c684e9e91
+3 -1
View File
@@ -189,19 +189,21 @@ function pfUI:UpdateFonts()
end
end
local translations
function pfUI:GetEnvironment()
-- load api into environment
for m, func in pairs(pfUI.api or {}) do
pfUI.env[m] = func
end
if pfUI_config and pfUI_config.global and pfUI_config.global.language and not pfUI.env.T then
if pfUI_config and pfUI_config.global and pfUI_config.global.language and not translations then
local lang = pfUI_config and pfUI_config.global and pfUI_config.global.language and pfUI_translation[pfUI_config.global.language] and pfUI_config.global.language or GetLocale()
pfUI.env.T = setmetatable(pfUI_translation[lang] or {}, { __index = function(tab,key)
local value = tostring(key)
rawset(tab,key,value)
return value
end})
translations = true
end
pfUI.env._G = getfenv(0)