local e=import("\046\047\066\097\115\101\073\110\115\116\097\110\099\101")local P=import("\046\046\047\073\110\115\116\097\110\099\101\080\114\111\112\101\114\116\121")local G=import("\046\046\047\106\115\111\110")local U=e:extend("\076\111\099\097\108\105\122\097\116\105\111\110\084\097\098\108\101",{creatable=true})U.properties.SourceLocaleId=P.normal({getDefault=function()return"\101\110-\117\115"end})function U.init(P,e)(getmetatable(e)).instance.contents={}end function U.prototype.SetContents(P,e)(getmetatable(P)).instance.contents=G.decode(e)end function U.prototype.GetString(G,e,P)local U=(getmetatable(G)).instance.contents for G,U in ipairs(U)do if U.key==P then return U.values[e]end end return nil end return U
local BaseInstance = import("./BaseInstance")
local InstanceProperty = import("../InstanceProperty")
local json = import("../json")

local LocalizationTable = BaseInstance:extend("LocalizationTable", {
	creatable = true,
})

LocalizationTable.properties.SourceLocaleId = InstanceProperty.normal({
	getDefault = function()
		return "en-us"
	end,
})

function LocalizationTable:init(instance)
	getmetatable(instance).instance.contents = {}
end

function LocalizationTable.prototype:SetContents(contents)
	getmetatable(self).instance.contents = json.decode(contents)
end

function LocalizationTable.prototype:GetString(targetLocaleId, key)
	local contents = getmetatable(self).instance.contents

	for _, entry in ipairs(contents) do
		if entry.key == key then
			return entry.values[targetLocaleId]
		end
	end

	return nil
end

return LocalizationTable