Quantcast


phLib = {

	deepcopy = function(object)
		local lookup_table = {}
		local function _copy(object)
			if type(object) ~= "table" then
				return object
			elseif lookup_table[object] then
				return lookup_table[object]
			end
			local new_table = {}
			lookup_table[object] = new_table
			for index, value in pairs(object) do
				new_table[_copy(index)] = _copy(value)
			end
			return new_table
		end
		return _copy(object)
	end,

    getLocale = function(id,...)
        local msg = phLocale[id];
        if not msg then
            msg = id;
        end;
        return string.format(msg,...);
    end,

    registerLocales = function(table)
        for id,msg in pairs(table) do
            phLocale[id] = msg;
        end;
    end,

}

phLocale = {
}