Content deleted Content added
Jackmcbarn (talk | contribs) add quick test thing |
Jackmcbarn (talk | contribs) rewrite |
||
Line 2:
function translationwrapper.create(args)
-- args.to contains English keys and translated values
if not args.temapping then▼
-- if the value is a table, any of that table's values are valid translations
args.temapping = {}▼
-- args.from contains translated keys and English values
for k,v in pairs(args.etmapping) do▼
-- optional if args.to doesn't rely on __index
-- args.src is the table being wrapped
if type(v) == 'table' then
for _,v2 in ipairs(v) do
args.
end
else
args.
end
end
Line 17 ⟶ 22:
local mt = {}
function mt.__index(t, k)
local
▲ if type[etmapping] == 'table' then
for _,v in ipairs(etmapping) do▼
end▼
end
end
▲ return nil
else▼
return src[k]▼
▲ end
elseif etmapping ~= nil then▼
if retval ~= nil then
return retval
return nil▼
else▼
return src[k]▼
end
return src[k]▼
end
end
function mt.__newindex(t, k, v)
if type(k) ~= 'string' then
▲ if type[etmapping] == 'table' then
end
if type[to] == 'table' then
args.src[k] = nil
else▼
if k2 == 1 then
args.src[v2] = v
▲ else
args.src[v2] = nil
end
args.src[k] = nil
end
▲ src[etmapping] = v
end
function mt.__pairs(t)
end
function mt.__ipairs(t)
|