Module:RetroKey

Vanuit Wiktionary, die vrye woordeboek.

Dokumentasie vir hierdie module kan geskep word by: Module:RetroKey/doc

local chars = {
 [" "] = "", ["!"] = "", ["'"] = "", ["+"] = "", [","] = "", ["-"] = "",  
 ["."] = "",  ["/"] = "", ["?"] = "",    
 ["á"] = "a",  ["à"] = "a",  ["â"] = "a",  ["ä"] = "a",  ["ã"] = "a",  ["å"] = "a",
 ["ç"] = "c",
 ["é"] = "e", ["è"] = "e", ["ê"] = "e", ["ë"] = "e",
 ["í"] = "i", ["î"] = "i", ["ï"] = "i",
 ["ñ"] = "n",
 ["ó"] = "o", ["ô"] = "o", ["ö"] = "o", ["ø"] = "o",
 ["ú"] = "u", ["ù"] = "u", ["û"] = "u", ["ü"] = "u",
}
local p = {}
function p.main()
  local title = mw.title.getCurrentTitle()
  local key1 = title.text
  local key2 = mw.ustring.lower(title.text)
  key1 = mw.ustring.gsub(key1, '(%u)', '@' )
  key2 = mw.ustring.gsub(key2, '.', chars)
  key2 = key1 .. " " .. key2
  local bound = mw.ustring.len( key2 )
  local retro = mw.ustring.char( mw.ustring.codepoint( key2 , bound) )
  i = 1
  while i < bound do
    retro = retro .. mw.ustring.char( mw.ustring.codepoint( key2 , bound - i ) )
    i = i + 1
  end
  return retro
end
return p