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