local X=import("\046\047\066\097\115\101\073\110\115\116\097\110\099\101")local c=import("\046\046\047\073\110\115\116\097\110\099\101\080\114\111\112\101\114\116\121")local n=import("\046\046\047\106\115\111\110")local o=X:extend("\076\111\099\097\108\105\122\097\116\105\111\110\084\097\098\108\101",{creatable=true})o.properties.SourceLocaleId=c.normal({getDefault=function()return"\101\110-\117\115"end})function o.init(c,X)(getmetatable(X)).instance.contents={}end function o.prototype.SetContents(c,X)(getmetatable(c)).instance.contents=n.decode(X)end function o.prototype.GetString(n,X,c)local o=(getmetatable(n)).instance.contents for n,o in ipairs(o)do if o.key==c then return o.values[X]end end return nil end return o
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