Ҷаҳиш ба мӯҳтаво

Модул:flexlink

Аз Wiktionary

Documentation for this module may be created at Модул:flexlink/doc

local m = {}

function m.convert(frame)
  if (frame.args.spr ~= "la") then
    return frame.args[1]
  end
  return noMacron(frame.args[1])
end


function noMacron(str)
  local newstr = ""
  local newcp = 0
  local cp = 0
  local from = "ĀāĒēĪīŌōŪūȲȳ"
  local frto = "AaEeIiOoUuYy"

  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

  return newstr

end

return m