Modul:dv-translit
- Berikut merupakan pendokumenan yang dijana oleh Modul:pendokumenan/functions/translit. [sunting]
- Pautan berguna: senarai sublaman • pautan • transklusi • kes ujian • kotak pasir
Modul ini akan mentransliterasi Bahasa Dhivehi teks.
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:dv-translit/testcases.
Functions
suntingtr(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 = {
['ހ']='h', ['ށ']='sh' , ['ނ']='n' , ['ރ']='r' , ['ބ']='b' ,
['ޅ']='ḷ' , ['ކ']='k' , ['އ']='' , ['ވ']='v' , ['މ']='m' ,
['ފ']='f' , ['ދ']='d' , ['ތ']='t' , ['ލ']='l' , ['ގ']='g' ,
['ޏ']='ñ' , ['ސ']='s' , ['ޑ']='ḍ' , ['ޒ']='z' , ['ޓ']='ṭ' ,
['ޔ']='y' , ['ޕ']='p' , ['ޖ']='j' , ['ޗ']='c' , ['ޱ']='ṇ' ,
['ޘ']='ṯ' , ['ޙ']='ḥ' , ['ޚ']='x' , ['ޛ']='ź' , ['ޜ']='ž' ,
['ޝ']='š' , ['ޞ']='ş' , ['ޟ']='ḋ' , ['ޠ']='ţ' , ['ޡ']='ẓ' ,
['ޢ']='ʿ' , ['ޣ']='ġ' , ['ޤ']='q' , ['ޥ']='w' ,
}
local diacritics = {
['\222\166']='a' , ['\222\167']='ā' , ['\222\168']='i' , ['\222\169']='ī' , ['\222\170']='u' ,
['\222\171'] = 'ū' , ['\222\172']='e' , ['\222\173']='ē' , ['\222\174']='o' , ['\222\175']='ō' , ['\222\176']='',
-- no diacritic
[""] = 'a'
}
-- translit any words or phrases
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
'([ހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޱޘޙޚޛޜޝޞޟޠޡޢޣޤޥ])'..
'([\222\166\222\167\222\168\222\169\222\170\222\171\222\172\222\173\222\174\222\175\222\176]?)',
function(c, d)
return consonants[c] .. diacritics[d]
end)
return text
end
return export