Modul:Guru-translit
Tampilan
Dokumentasi untuk modul ini dapat dibuat di Modul:Guru-translit/doc
local export = {}
local conv = {
--symbol
["ੴ"] = "ek oaṅkār",
--consonants without nukta
["ਸ"] = "s",
["ਹ"] = "h",
["ਕ"] = "k", ["ਖ"] = "kh", ["ਗ"] = "g", ["ਘ"] = "gh", ["ਙ"] = "ṅ",
["ਚ"] = "ch", ["ਛ"] = "cḥ", ["ਜ"] = "j", ["ਝ"] = "jh", ["ਞ"] = "ñ",
["ਟ"] = "ṭ", ["ਠ"] = "ṭh", ["ਡ"] = "ḍ", ["ਢ"] = "ḍh", ["ਣ"] = "ṇ",
["ਤ"] = "t", ["ਥ"] = "th", ["ਦ"] = "d", ["ਧ"] = "dh", ["ਨ"] = "n",
["ਪ"] = "p", ["ਫ"] = "ph", ["ਬ"] = "b", ["ਭ"] = "bh", ["ਮ"] = "m",
["ਯ"] = "y", ["ਰ"] = "r", ["ਲ"] = "l", ["ਵ"] = "v", ["ੜ"] = "ṛ",
--consonants with nukta
["ਸ਼"] = "sh",
["ਖ਼"] = "kḥ",
["ਗ਼"] = "ġ",
["ਜ਼"] = "z",
["ਫ਼"] = "f",
["ਲ਼"] = "ḷ",
["ਕ਼"] = "q",
-- vowels
["ਾ"] = "ā",
["ਿ"] = "i", ["ੀ"] = "ī",
["ੁ"] = "u", ["ੂ"] = "ū",
["ੇ"] = "e", ["ੈ"] = "ae",
["ੋ"] = "o", ["ੌ"] = "au",
-- other diacritics
["ੰ"] = "N", --ṭippi: nasalize
["ਂ"] = "N", --bindi: nasalize
["ੱ"] = "", --addak: germinate
["੍"] = "", --halant, supresses the inherent vowel "a"
["ਃ"] = "h", --voiceless "h" sound (tone raiser)
-- independent vowels
["ਅ"] = "a", ["ਆ"] = "ā",
["ਇ"] = "e", ["ਈ"] = "ē",
["ਉ"] = "u", ["ਊ"] = "ū",
["ਏ"] = "e", ["ਐ"] = "ae",
["ਓ"] = "o", ["ਔ"] = "au",
-- digits
["੦"] = "0", ["੧"] = "1", ["੨"] = "2", ["੩"] = "3", ["੪"] = "4",
["੫"] = "5", ["੬"] = "6", ["੭"] = "7", ["੮"] = "8", ["੯"] = "9",
}
local nasal_assim = {
["[kg]h?"] = "ṅ",
["[cj]h?"] = "ñ",
["[ṭḍ]h?"] = "ṇ",
["[td]h?"] = "n",
["[pb]h?"] = "m",
["n"] = "n",
["m"] = "m",
["s"] = "n",
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local c = "([ਸਹਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵੜː]਼?)"
local uae = "([ੳਅੲਉਊਆਇਈਏਐਓਔ])"
local y = "ਯ"
local v = "([a ਾ ਿ ੀ ੁ ੂ ੇ ੈ ੋ ੌ])"
local virama = "([੍]?)"
local addak = "([ੱ])"
local n = "([ੰਂ]?)"
local tippi = "([ੰ])"
local nukta = "([ਸਖਗਜਫਲਕ]਼)"
can_drop = mw.ustring.gsub(c,y,"")
no_virama = mw.ustring.gsub(v,virama,"")
text = text .. " "
--two consonants
text = mw.ustring.gsub(text,
c .. c,
"%1a%2") --example ਕਰ
--[[
-- Has no effect.
text = mw.ustring.gsub(text,
c .. v .. c,
"%1%2%3") --example ਸ਼ੇਰ
--]]
text = mw.ustring.gsub(text,
c .. c .. v ,
"%1a%2%3") --example ਦਰੀ
text = mw.ustring.gsub(text,
c .. v .. c .. v ,
"%1%2%3%4") --example ਖੀਰਾ
-- addak
text = mw.ustring.gsub(text,
c .. addak .. c,
"%1a%2%3") --example ਰੱਬ
text = mw.ustring.gsub(text,
c .. v .. addak .. c,
"%1%2%3%4") --example ਸਿੱਖ
text = mw.ustring.gsub(text,
c .. addak .. c .. v ,
"%1a%2%3%4") --example ਗੱਡੀ
text = mw.ustring.gsub(text,
c .. v .. addak .. c .. v ,
"%1%2%3%4%5") --example ਤਿੱਖਾ
-- paer vich haha
text = mw.ustring.gsub(text,
c .. c .. virama .. c,
"%1a%2%3%4") --example ਹੜ੍ਹ
text = mw.ustring.gsub(text,
c .. c .. virama .. c .. v,
"%1a%2%3%4%5") --example ਘੜ੍ਹੀ
text = mw.ustring.gsub(text,
c .. v .. c .. virama .. c .. v,
"%1%2%3%4%5%6") --example ਮਾੜ੍ਹੀ
-- tippi
text = mw.ustring.gsub(text,
c .. tippi .. c,
"%1a%2%3") --example ਬੰਦ
text = mw.ustring.gsub(text,
c .. v .. tippi .. c,
"%1%2%3%4") --example ਜਿੰਦ
text = mw.ustring.gsub(text,
c .. tippi .. c .. v,
"%1a%2%3%4") --example ਬੰਦੀ
text = mw.ustring.gsub(text,
c .. v .. tippi .. c .. v,
"%1%2%3%4%5") --example ਜ਼ਿੰਦਾ
--three consonants
text = mw.ustring.gsub(text,
c .."a" .. c .. c,
"%1a%2a%3") --example ਕਦਰ
text = mw.ustring.gsub(text,
c .. v .. c .. c,
"%1%2%3a%4") --example ਜਿਸਮ
text = mw.ustring.gsub(text,
c .. c .. v .. c,
"%1a%2%3%4") --example ਤਸੀਰ
text = mw.ustring.gsub(text,
c .. c .. c .. v,
"%1a%2%3%4") --example ਤਸਬੀ
text = mw.ustring.gsub(text,
c .. v .. c .. "a" .. c .. v,
"%1%2%3%4%5") --example ਖ਼ਾਲਸਾ
text = mw.ustring.gsub(text,
c .. v .. c .. v .. c .. v,
"%1%2%3%4%5%6") --example ਖ਼ੁਲਾਸਾ
-- addak
text = mw.ustring.gsub(text,
c .. addak .. c .. "a" .. c .. v,
"%1%2%3%4%5%6") --example ਨੱਠਣਾ
text = mw.ustring.gsub(text,
c .. v .. addak .. c .. "a" .. c .. v,
"%1%2%3%4%5%6") --example ਸਿੱਖਣਾ
-- tippi
text = mw.ustring.gsub(text,
c .. tippi .. c .. c,
"%1a%2%3a%4") --example ਜੰਗਲ
text = mw.ustring.gsub(text,
c .. tippi .. c .. v,
"%1a%2%3%4") --example ਰੰਗਲਾ
text = mw.ustring.gsub(text,
c .. v .. tippi .. c .. c .. v,
"%1%2%3%4a%5%6") --example ਜ਼ਿੰਦਗੀ
-- paer vich haha
text = mw.ustring.gsub(text,
c .. "a" .. c .. virama .. c .. "a" .. c .. v,
"%1a%2%3%4%5%6") --example ਪੜ੍ਹਣਾ
--four consonants
text = mw.ustring.gsub(text,
c .. c .. c .. c,
"%1a%2%3a%4") --example ਸਰਬਤ
text = mw.ustring.gsub(text,
c .. v .. c .. c .. c,
"%1%2%3%4a%5") --example ਕੁਦਰਤ
text = mw.ustring.gsub(text,
c .. "a" .. c .. v .. c .. c,
"%1a%2%3%4a%5") --example ਕਬੂਤਰ
text = mw.ustring.gsub(text,
c .. c .. c .. v .. c,
"%1a%2%3%4%5") --example
text = mw.ustring.gsub(text,
c .. c .. c .. c .. v,
"%1a%2%3%4%5") --example
text = mw.ustring.gsub(text,
c .. c .. c .. v .. c .. v,
"%1a%2%3%4%5%6") --example ਦਰਵਾਜ਼ਾ
-- tippi
text = mw.ustring.gsub(text,
c .. "a" .. tippi .. c .. "a" .. c .. v .. c,
"%1a%2%3%4%5%6") --example ਧੰਨਵਾਦ
text = mw.ustring.gsub(text,
c .. tippi .. c .. c .. v .. c,
"%1a%2%3%4%5") --example ਫ਼ਰਜ਼ੰਦ
--addak
text = mw.ustring.gsub(text,
c .. "a" .. addak .. c .. "a" .. c .. c,
"%1a%2%3%4a%5") --example ਯੱਕਦਮ
-- five consonants
text = mw.ustring.gsub(text,
c .. v .. c .. c .. "a" .. c .. v .. c,
"%1%2%3a%4%5%6%7") --example ਵੇਪਰਵਾਹ
text = mw.ustring.gsub(text,
c .. v .. c .. "a" .. c .. c .. "a" .. c .. v,
"%1%2%3%4a%5%6%7") --example ਪਾਰਦਰਸ਼ੀ
--addak
text = mw.ustring.gsub(text,
c .. v .. addak .. c .. c .. c .. v .. c,
"%1%2%3%4a%5%6%7%8") --example ਸ਼ੁੱਕਰਵਾਰ
text = mw.ustring.gsub(text,
c .. "a" .. c .. c .. "a" .. c .. "a" .. addak .. c,
"%1a%2a%3%4a%5%6") --example ਮਗਰਮੱਛ
text = mw.ustring.gsub(text,
c .. v .. c .. v .. c .. c .. "a" .. c .. c .. v,
"%1%2%3%4%5a%6a%7%8%9") --example ਯੂਨੀਵਰਸਟੀ
-- uae
text = mw.ustring.gsub(text,
uae .. c .. c ,
"%1%2a%3") --example ਅਦਬ
text = mw.ustring.gsub(text,
uae .. c .. "a".. c .. v ,
"%1%2%3%4") --example ਆਖਣਾ
text = mw.ustring.gsub(text,
uae .. tippi .. c .. "a".. c .. v ,
"%1%2%3%4%5") --example ਅੰਤੜੀ
text = mw.ustring.gsub(text,
uae .. c .. "a".. c .. c ,
"%1%2%3a%4") --example ਅਫ਼ਸਰ
text = mw.ustring.gsub(text,
uae .. c .. "a" .. c .. v .. c .. v ,
"%1%2%3%4%5%6") --example ਅਲਮਾਰੀ
text = mw.ustring.gsub(text,
uae .. c .. "a" .. c .. v .. c ,
"%1%2%3%4%5") --example ਇਕਰਾਰ
text = mw.ustring.gsub(text,
uae .. "ਸ" .. "ਤ" .. "a" .. c .. v ,
"%1st%2%3") --example ਉਸਤਰਾ
text = mw.ustring.gsub(text,
c .. v .. uae .. c .. c ,
"%1%2%3%4a%5") --example ਸਾਈਕਲ
text = mw.ustring.gsub(text,
c .. v .. c .. v .. uae .. c .. "a" .. c .. v,
"%1%2%3%4%5%6%7%8") --example ਵਿਦਿਆਰਥੀ
text = mw.ustring.gsub(text,can_drop .. "ਈ", "%1aī") -- example ਕਈ
text = mw.ustring.gsub(text,v .. "ਸ" .. "a" .. "ਤ" , "%1st") --example ਦੋਸਤ
text = mw.ustring.gsub(text,can_drop .. "ਸ" .. "a" .. "ਤ" , "%1st") --example ਹਸਤੀ
text = mw.ustring.gsub(text,v .. "ā" .. "ਸ" .. "ਤ", "%1āsat" ) -- example ਰਿਆਸਤ, ਸਿਆਸਤ
text = mw.ustring.gsub(text,"ਸ" .. "a" .. "ਟ", "sṭ")
text = mw.ustring.gsub(text,"ਸ" .. "a" .. "ਥ", "sth")
text = mw.ustring.gsub(text,"ਸ਼" .. "a" .. "ਤ", "sht")
text = mw.ustring.gsub(text,"ਸ਼" .. "a" .. "ਥ", "shth")
text = mw.ustring.gsub(text,"ਸ਼" .. "a" .. "ਟ", "shṭ")
text = mw.ustring.gsub(text,nukta,conv)
text = mw.ustring.gsub(text,".",conv)
for key,val in pairs(nasal_assim) do
text = mw.ustring.gsub(text,"N("..key..")",val.."%1")
end
text = mw.ustring.gsub(text,"([aiueēoāīū])N ", "%1̃ ")
text = mw.ustring.gsub(text,"(.?)N", "%1̃")
text = mw.ustring.gsub(text,"ː(.)","%1%1")
text = mw.ustring.gsub(text," ?।",".")
text = mw.ustring.gsub(text," $","")
return mw.ustring.toNFC(text)
end
return export