Content deleted Content added
Jackmcbarn (talk | contribs) handle false cognates |
Jackmcbarn (talk | contribs) add pairs support |
||
Line 1:
local translationwrapper = {}
local function translatenext(invariant)
local k, v = next(invariant.args.src, invariant.k)
invariant.k = k
if k == nil then
return nil
elseif type(k) ~= 'string' then
return k, v
end
local from = invariant.args.from[k]
if from ~= nil then
return from, v
elseif invariant.args.to[k] == nil then
return k, v
else
-- skip this key. tail call
return translatenext(invariant)
end
end
function translationwrapper.create(args)
-- args.to contains English keys and translated values
Line 69 ⟶ 87:
end
function mt.__pairs(t)
return translatenext, {args = args}
end
function mt.__ipairs(t)
|