模組:Inc-mbn-translit
這個模組將轉寫印度-雅利安語支當中之一的文字。
最好不要直接從模板或其他模組呼叫此模組;要從模板中使用它,
請使用{{xlit}}
;
要從模組中使用它,請使用Module:languages#Language:transliterate。
關於測試用例,請見Module:Inc-mbn-translit/testcases。
函式
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. - When the transliteration fails, returns
nil
.
local export = {}
local consonants = {
["ক"]="k", ["খ"]="kh", ["গ"]="g", ["ঘ"]="gh", ["ঙ"]="ṅ", ["চ"]="c", ["ছ"]="ch", ["জ"]="j", ["ঝ"]="jh", ["ঞ"]="ñ", ["ট"]="ṭ", ["ঠ"]="ṭh", ["ড"]="ḍ", ["ড়"]="ṛ", ["ঢ"]="ḍh", ["ঢ়"]="ṛh", ["ণ"]="ṇ", ["ত"]="t", ["থ"]="th", ["দ"]="d", ["ধ"]="dh", ["ন"]="n", ["প"]="p", ["ফ"]="ph", ["ব"]="b", ["ভ"]="bh", ["ম"]="m", ["য"]="j", ["য়"]="ẏ", ["র"]="r", ["ল"]="l", ["শ"]="ś", ["ষ"]="ś", ["স"]="ś", ["হ"]="h",
}
local diacritics = {
["া"]="ā", ["ি"]="i", ["ী"]="i", ["ু"]="u", ["ূ"]="u", ["ৃ"]="ri", ["ে"]="e", ["ৈ"]="ôi", ["ো"]="o", ["ৌ"]="au", ["্"]="",
}
local tt = {
-- vowels
["অ"]="a", ["আ"]="ā", ["ই"]="i", ["ী"]="i", ["উ"]="u", ["ঊ"]="u", ["ঋ"]="ri", ["এ"]="e", ["ঐ"]="ai", ["ও"]="o", ["ঔ"]="au",
-- candrabindu
["ঁ"] = "̃",
-- anusvara
["ং"]="ṅ",
-- visarga
["ঃ"]="ḥ",
--punctuation
["।"]=".", --danda
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
"([কখগঘঙচছজঝঞটঠডঢণতথদধনপফবরভমযলশষসহ]়?)"..
"([a্িুৃেোাীূৈৌ]?)",
function(c, d)
if not consonants[c] then
return c
end
if d == "" then
return consonants[c] .. "a"
else
return consonants[c] .. diacritics[d]
end
end)
text = mw.ustring.gsub(text, ".", tt)
return text
end
return export