This module will transliterate Old Punjabi language text.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{xlit}}
.
Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:inc-opa-Guru-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local conv = {
--consonants without nukta
= "s",
= "h",
= "k", = "kh", = "g", = "gh", = "ṅ",
= "c", = "ch", = "j", = "jh", = "ñ",
= "ṭ", = "ṭh", = "ḍ", = "ḍh", = "ṇ",
= "t", = "th", = "d", = "dh", = "n",
= "p", = "ph", = "b", = "bh", = "m",
= "y", = "r", = "l", = "v", = "ṛ",
-- vowels
= "ā",
= "i", = "ī",
= "u", = "ū",
= "e", = "ai",
= "o", = "au",
-- other diacritics
= "ṃ", --ṭippi: nasalize
= "ṃ", --bindi: nasalize
= "", --halant, supresses the inherent vowel "a"
-- independent vowels
= "a", = "ā",
= "i", = "ī",
= "u", = "ū",
= "e", = "ai",
= "o", = "au",
-- digits
= "0", = "1", = "2", = "3", = "4",
= "5", = "6", = "7", = "8", = "9",
}
local nasal_assim = {
h?"] = "ṅ",
h?"] = "ñ",
h?"] = "ṇ",
h?"] = "n",
h?"] = "m",
= "n",
= "m",
= "n",
= "ñ",
= "ṅ",
}
-- translit any words or phrases
function export.tr(text, lang, sc)
local c = "(਼?)"
local y = "ਯ"
local v = "()"
local virama = "੍"
local n = "(?)"
local no_virama = mw.ustring.gsub(v,virama,"")
text = text .. " "
text = mw.ustring.gsub(text,c,"%1a")
text = mw.ustring.gsub(text,"a"..v,"%1")
text = mw.ustring.gsub(text,".",conv)
for key,val in pairs(nasal_assim) do
text = mw.ustring.gsub(text,"ṃ("..key..")",val.."%1")
end
text = mw.ustring.gsub(text," ?",".")
text = mw.ustring.gsub(text," $","")
text = mw.ustring.gsub(text,"hh","h") -- ੍ਹ੍ਹ ਨ੍ਹ੍ਹ
text = mw.ustring.gsub(text,"yy","y") -- ੍ਯ੍ਯ ਖ੍ਯ੍ਯ
return mw.ustring.toNFC(text)
end
return export