มอดูล:dng-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate ภาษาดุงกาน 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:dng-translit/testcases.
Functions
แก้ไข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 gsub = mw.ustring.gsub
local u = mw.ustring.char
local tab = {
["б"]="ป", ["п"]="พ", ["м"]="ม", ["ф"]="ฟ", ["в"]="ว",
["д"]="ต", ["т"]="ท", ["н"]="น", ["л"]="ล",
["з"]="จ", ["ц"]="ช", ["с"]="ซ", ["р"]="ร",
["җ"]="จ̱", ["ч"]="ช̱", ["ш"]="ซ̱", ["щ"]="ฌ", ["ж"]="ร̱", ["й"]="ย",
["г"]="ก", ["к"]="ค", ["ң"]="ง", ["х"]="ฮ",
["ы"]="ื", ["и"]="ี", ["ў"]="ู", ["ү"]="ฺวื",
["а"]="า", ["я"]="↶เีย", --ia also ยา
["ә"]="↶เอ̂", ["е"]="ีอ↶เ", --ie also ย↶เ
["э"]="↶แ", ["о"]="อ̂", ["ё"]="ีออ̂", --iɔ also ยอ̂
["у"]="ุ", ["ю"]="ีอ↶โว", --ia also ย↶โว
["ъ"]=u(0x02BA), ["ь"]=u(0x02B9), --Russian loanwords
}
local tab2 = {
["уа"]="ัว", --ua
["уә"]="ูอ↶เอ̂", --uɤ
["уэ"]="ูอ↶แ", --uɛ
["уо"]="ูออ̂", --uɔ
["үа"]="ฺวือา", --ya
["үә"]="ฺวือ↶เอ̂", --yɤ
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
text = mw.ustring.lower(text)
text = gsub(text, "^(эр)", "อ↶เอ̂ร") --əɻ
text = gsub(text, "([%s%p])(эр)", "%2อ↶เอ̂ร")
text = gsub(text, "^([ыиўүаәэоу])", "อ%1")
text = gsub(text, "([%s%p])([ыиўүаәэоу])", "%2อ%1")
text = gsub(text, "^(я)", "ยา")
text = gsub(text, "([%s%p])(я)", "%2ยา")
text = gsub(text, "^(е)", "เย")
text = gsub(text, "([%s%p])(е)", "%2เย")
text = gsub(text, "^(ё)", "ยอ̂")
text = gsub(text, "([%s%p])(ё)", "%2ยอ̂")
text = gsub(text, "^(ю)", "ย↶โว")
text = gsub(text, "([%s%p])(ю)", "%2ย↶โว")
text = gsub(text, "[уү][аәэо]", tab2)
text = gsub(text, ".", tab)
text = gsub(text, "([ก-ฮ]̱?)↶([เแโ])", "%2%1")
return text
end
return export