if not dict then lang = "german" dict = {}; fname = "F:\\games\\rpg\\minetest-0415server\\mods\\basic_translate\\"..lang; local f = _G.assert(_G.io.open(fname, "r"));local dicts = f:read("*all");f:close() step = 0; maxwords = 10000; i=0 while(step c or a b -> d, where data for a = {{[de] = c},{[b] = d} local found = false local defaultv = "" for j=1,#data do for key,v in pairs(data[j]) do local keylen = string.len(key) local pattern = string.sub(input,i1+1,i1+keylen) if deb then say("pattern '" .. pattern .. "' key '" .. key .. "' len " .. keylen) end if key == "" then defaultv = v elseif pattern == key then found = true; if deb then say(word .. " " .. pattern .. " -> match key " .. key) end out = out .. " " .. v; i1 = i1+string.len(key)+1 -- skip to after key end end if found then break end end if not found then out = out .. " " .. defaultv end end else out = out .. " " .. word end i=i1 if deb then say("next word at i " .. i1 .. " remainder " .. string.sub(input,i1)) end end return out end -- say(translate("hello world")) self.listen(1) end speaker,msg = self.listen_msg() if msg then if string.sub(msg,1,1) == "?" then msg = string.sub(msg,2) local transmsg = translate(msg); _G.minetest.chat_send_all("TRANSLATOR> " .. transmsg) end end