Jump to content

Module:Deranize: Difference between revisions

Support diphthong reform
(add diphthong mark in VF sequences)
(Support diphthong reform)
Line 58: Line 58:
   ["diphthong"] = "󱛎",
   ["diphthong"] = "󱛎",
   [""] = "",
   [""] = "",
  -- diphthong reform
  ["aı"] = "󱚶", -- DERANI LETTER DUDEO
  ["ao"] = "󱚳", -- DERANI LETTER PIPOQ
  ["eı"] = "󱚸", -- DERANI LETTER ZOZEO
  ["oı"] = "󱚽", -- DERANI LETTER NHANHOQ
}
}


Line 72: Line 77:
   ["_"] = "󱛛", -- compatibility nbsp
   ["_"] = "󱛛", -- compatibility nbsp
}
}
local reform = false


function deranize_word(word)
function deranize_word(word)
Line 95: Line 102:
     end
     end


    local di = deranimap[media..final]
    if di and reform then medial = di final = "" end
     local glyphs = {initial, tone, medial}
     local glyphs = {initial, tone, medial}
     if initial == "" and is_first_syllable then glyphs[1] = "'" end
     if initial == "" and is_first_syllable then glyphs[1] = "'" end
Line 102: Line 111:
       glyphs[2], glyphs[3] = glyphs[3], glyphs[2]
       glyphs[2], glyphs[3] = glyphs[3], glyphs[2]
     end
     end
    local v = medial..final
     if di and not reform then
     if v == "aı" or v == "ao" or v == "eı" or v == "oı" then
       glyphs[#glyphs+1] = "diphthong"
       glyphs[#glyphs+1] = "diphthong"
     elseif final ~= "" then
     elseif final ~= "" then
       glyphs[#glyphs+1] = "hiatus"
       glyphs[#glyphs+1] = "hiatus"
     end
     end
     for j, fin in ipairs(mw.text.split(final, "")) do
     if reform then
      if j > 1 then glyphs[#glyphs+1] = "diphthong" end
      glyphs[#glyphs+1] = final
      glyphs[#glyphs+1] = fin
    else
      for j, fin in ipairs(mw.text.split(final, "")) do
        if j > 1 then glyphs[#glyphs+1] = "diphthong" end
        glyphs[#glyphs+1] = fin
      end
     end
     end
     if coda ~= "" then
     if coda ~= "" then
Line 128: Line 140:


function deranize(frame)
function deranize(frame)
   assert(frame.args[1] ~= nil and frame.args[2] == nil, "This function requires exactly one argument")
   assert(frame.args[1] ~= nil, "This function requires at least one argument")
  reform = frame.args[2] ~= nil
   local text = u.gsub(u.lower(u.toNFD(frame.args[1])), "i", "ı")
   local text = u.gsub(u.lower(u.toNFD(frame.args[1])), "i", "ı")
   local converted = u.gsub(text, "(%S+)", deranize_word)
   local converted = u.gsub(text, "(%S+)", deranize_word)