Zum Inhalt springen

Modul:fa-translit

Vun Wiktionary

[[|*]]


--[[
Transliteration for Persian.
]]
local M = {}
 
local tt = {
    ["ا"]='â', ["ب"]='b', ["پ"]='p', ["ت"]='t', ["ث"]='s', ["ج"]='j', ["چ"]='č', ["ح"]='h', ["خ"]='x', 
    ["د"]='d', ["ذ"]='z', ["ر"]='r', ["ز"]='z', ["ژ"]='ž', ["س"]='s', ["ش"]='š', ["ص"]='s', ["ض"]='z', 
    ["ط"]='t', ["ظ"]='z', ["ع"]='’', ["غ"]='ğ', ["ف"]='f', ["ق"]='q', ["ک"]='k', ["گ"]='g', ["ل"]='l', 
    ["م"]='m', ["ن"]='n', ["و"]='u', ["ه"]='h', ["ی"]='i', ["آ"]='â', ["ﮥ"]='eye',
-- displaying on separate lines as the viewing becomes distorted on these combinations
    ["ء"]="'",
    ["ئ"]="'", 
    ["ؤ"]="'",
    ["أ"]="'",
    -- diacritics
    ["َ"]="a", -- fathe, zabar
    ["ِ"]="e", -- kasre, zir
    ["ُ"]="o", -- zamme, piš
    ["ْ"]="", --jazm, sokun - no vowel
    ["اً"]="an",
    ["‌"]="-", -- ZWNJ (zero-width non-joiner)
    -- ligatures
    ["ﻻ"]="lâ",
    ["ﷲ"]="llâh",
    -- kashida
    ["ـ"]="", -- kashida, no sound
    -- numerals
    ["۱"]="1", ["۲"]="2", ["۳"]="3", ["۴"]="4", ["۵"]="5",
    ["۶"]="6", ["٧"]="7", ["٨"]="8", ["٩"]="9", ["۰"]="0",
    -- punctuation (leave on separate lines)
    ["؟"]="?", -- question mark
    ["،"]=",", -- comma
    ["؛"]=";" -- semicolon
};
 
function M.tr(f)--translit any words or phrases
    local text = mw.ustring.gsub(f.args[1], '.', tt)
    text = mw.ustring.gsub(text, "(.)ّ", "%1%1") -- tašdid
    return text
    -- return (mw.ustring.gsub(f.args[1], '.', tt))
end
 
return M