lang: return datas instead of directly putting them in self.datas

This commit is contained in:
Kazhnuz 2019-04-13 18:42:47 +02:00
parent f40d2c9912
commit 59029068f1

View file

@ -31,8 +31,8 @@ local TRANSLATION_PATH = "datas/languages/"
function LanguageManager:new(controller) function LanguageManager:new(controller)
self.controller = controller self.controller = controller
self.datas = self:getTranslationData()
self:setLang(self.controller.options.data.language) self:setLang(self.controller.options.data.language)
self:getTranslationData()
end end
function LanguageManager:setLang(lang) function LanguageManager:setLang(lang)
@ -46,12 +46,13 @@ end
function LanguageManager:getTranslationData() function LanguageManager:getTranslationData()
local _path = TRANSLATION_PATH .. "init.lua" local _path = TRANSLATION_PATH .. "init.lua"
local fileinfo = love.filesystem.getInfo(_path) local fileinfo = love.filesystem.getInfo(_path)
local datas = nil
if fileinfo ~= nil then if fileinfo ~= nil then
self.datas = require(TRANSLATION_PATH) datas = require(TRANSLATION_PATH)
else
self.datas = nil
end end
return datas
end end
function LanguageManager:getStringList(library, file) function LanguageManager:getStringList(library, file)