Modul:sieheAuch

Aus Wiktionary, dem freien Wörterbuch

-- Erzeugt eine diakritikalose Form eines Strings für die [[:Kategorie:siehe auch]]
-- Konvertiert Großbuchstaben zu Kleinbuchstaben, entfernt Leerzeichen, Zeichen . und - _
-- [[Modul:sieheAuch/testcases]]

local m = {}

function m.convert(frame)
  
  return sieheAuchStr(frame.args[1],frame.args[2])

end


function sieheAuchStr(str,sprache)
  local n = 0
  local newstr = ""
  local newcp = 0
  local cp = 0
  local from = "äȁâàȃăãáāąåḃċćĉčçḋďđḍėëȅêěèȇĕẽéēęḟġĝğģḣĥħḥıïȉîìȋĭĩíīįĵḳķĺľłŀḷļ"
  local frto = "aaaaaaaaaaabcccccddddeeeeeeeeeeeefgggghhhhiiiiiiiiiiijkkllllll"
  from = from .. "ṁṃṅńňñņöȍőôòȏŏõóōøṗṙȑȓřŕṛŗṡśŝšṣșşṫťŧṭţüȕűûùȗŭũúūůųṿŵÿŷýỹȳźżžѝ"
  frto = frto .. "mmnnnnnoooooooooooprrrrrrrssssssstttttuuuuuuuuuuuuvwyyyyyzzzи"
  from = from .. "άὰᾶἀἁἄἂἆἅἃἇέὲἐἑἔἒἕἓήὴῆἠἡἤἢἦἥἣἧίὶῖἰἱἴἲἶἵἳἷϊΐῒῗόὸὀὁὄὂὅὃύὺῦὐὑὔὒὖὕὓὗϋΰῢῧώὼῶὠὡὤὢὦὥὣὧῤῥ"
  frto = frto .. "αααααααααααεεεεεεεεηηηηηηηηηηηιιιιιιιιιιιιιιιοοοοοοοουυυυυυυυυυυυυυυωωωωωωωωωωωρρ"
  from = from .. "ᾳᾴᾲᾷᾀᾁᾄᾂᾆᾅᾃᾇῃῄῂῇᾐᾑᾔᾒᾖᾕᾓᾗῳῴῲῷᾠᾡᾤᾢᾦᾥᾣᾧ"
  frto = frto .. "ααααααααααααηηηηηηηηηηηηωωωωωωωωωωωω"

  str,n = mw.ustring.gsub(str,"%-","")
  str,n = mw.ustring.gsub(str,"%.","")
  str,n = mw.ustring.gsub(str,"_","")
  str,n = mw.ustring.gsub(str," ","")
  str = mw.ustring.lower(str)

  for cp in mw.ustring.gcodepoint(str) do
    newcp = cp
    for idx = 1, mw.ustring.len( from ) do
      if (cp == mw.ustring.codepoint( from, idx)) then
        newcp = mw.ustring.codepoint( frto, idx)
      end
    end
    newstr = newstr .. mw.ustring.char(newcp)
  end

  if mw.ustring.len( newstr ) == 0 then
    return "-"
  end
  return newstr

end

return m