模組:Dv-translit
這個模組將轉寫迪維希語的文字。
最好不要直接從模板或其他模組呼叫此模組;要從模板中使用它,
請使用{{xlit}}
;
要從模組中使用它,請使用Module:languages#Language:transliterate。
關於測試用例,請見Module:Dv-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 u = mw.ustring.char
local consonants = {
['ހ'] = 'h', ['ށ'] = 'sh', ['ނ'] = 'n', ['ރ'] = 'r', ['ބ'] = 'b',
['ޅ'] = 'ḷ', ['ކ'] = 'k', ['އ'] = '', ['ވ'] = 'v', ['މ'] = 'm',
['ފ'] = 'f', ['ދ'] = 'd', ['ތ'] = 't', ['ލ'] = 'l', ['ގ'] = 'g',
['ޏ'] = 'ñ', ['ސ'] = 's', ['ޑ'] = 'ḍ', ['ޒ'] = 'z', ['ޓ'] = 'ṭ',
['ޔ'] = 'y', ['ޕ'] = 'p', ['ޖ'] = 'j', ['ޗ'] = 'c', ['ޱ'] = 'ṇ',
['ޘ'] = 'ṯ', ['ޙ'] = 'ḥ', ['ޚ'] = 'x', ['ޛ'] = 'ź', ['ޜ'] = 'ž',
['ޝ'] = 'š', ['ޞ'] = 'ş', ['ޟ'] = 'ḋ', ['ޠ'] = 'ţ', ['ޡ'] = 'ẓ',
['ޢ'] = 'ʿ', ['ޣ'] = 'ġ', ['ޤ'] = 'q', ['ޥ'] = 'w',
}
local diacritics = {
[u(0x07A6)] = 'a', [u(0x07A7)] = 'ā', [u(0x07A8)] = 'i', [u(0x07A9)] = 'ī', [u(0x07AA)] = 'u',
[u(0x07AB)] = 'ū', [u(0x07AC)] = 'e', [u(0x07AD)] = 'ē', [u(0x07AE)] = 'o', [u(0x07AF)] = 'ō', [u(0x07B0)] = '',
--no diacritic
[''] = ''
}
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([ހ-ޥޱ])(['..u(0x07A6)..'-'..u(0x07B0)..']?)',
function(c, d)
return consonants[c] .. diacritics[d]
end)
return text
end
return export