Module:lep-translit
Appearance
- පහත දැක්වෙන උපදෙස්, Module:lep-translit/documentation හි පිහිටා ඇත. Module:lep-translit/documentation]]. [සංස්කරණය] Categories were auto-generated by Module:module categorization. [edit]
- ප්රයෝජනවත් සබැඳි: උප පිටු ලැයිස්තුව • සබැඳි • transclusions • testcases • sandbox
This module will transliterate Lepcha භාෂාව 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:lep-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 conv = {
[""] = "",
["\225\176\128"] = "k", --U+1C00
["\225\176\129"] = "kl", --U+1C01
["\225\176\130"] = "kh", --U+1C02
["\225\176\131"] = "g", --U+1C03
["\225\176\132"] = "gl", --U+1C04
["\225\176\133"] = "ng", --U+1C05
["\225\176\134"] = "c", --U+1C06
["\225\176\135"] = "ch", --U+1C07
["\225\176\136"] = "j", --U+1C08
["\225\176\137"] = "ny", --U+1C09
["\225\176\138"] = "t", --U+1C0A
["\225\176\139"] = "th", --U+1C0B
["\225\176\140"] = "d", --U+1C0C
["\225\176\141"] = "n", --U+1C0D
["\225\176\142"] = "p", --U+1C0E
["\225\176\143"] = "pl", --U+1C0F
["\225\176\144"] = "ph", --U+1C10
["\225\176\145"] = "f", --U+1C11
["\225\176\146"] = "fl", --U+1C12
["\225\176\147"] = "b", --U+1C13
["\225\176\148"] = "bl", --U+1C14
["\225\176\149"] = "m", --U+1C15
["\225\176\150"] = "ml", --U+1C16
["\225\176\151"] = "ts", --U+1C17
["\225\176\152"] = "tsh", --U+1C18
["\225\176\153"] = "dz", --U+1C19
["\225\176\154"] = "y", --U+1C1A
["\225\176\155"] = "r", --U+1C1B
["\225\176\156"] = "l", --U+1C1C
["\225\176\157"] = "h", --U+1C1D
["\225\176\158"] = "hl", --U+1C1E
["\225\176\159"] = "v", --U+1C1F
["\225\176\160"] = "s", --U+1C20
["\225\176\161"] = "sh", --U+1C21
["\225\176\162"] = "w", --U+1C22
["\225\176\163"] = "", --U+1C23
["\225\176\164"] = "y", --U+1C24
["\225\176\165"] = "r", --U+1C25
["\225\176\166"] = "á", --U+1C26
["\225\176\167"] = "i", --U+1C27
["\225\176\168"] = "o", --U+1C28
["\225\176\169"] = "ó", --U+1C29
["\225\176\170"] = "u", --U+1C2A
["\225\176\171"] = "ú", --U+1C2B
["\225\176\172"] = "e", --U+1C2C
["\225\176\173"] = "k", --U+1C2D
["\225\176\174"] = "m", --U+1C2E
["\225\176\175"] = "l", --U+1C2F
["\225\176\176"] = "n", --U+1C30
["\225\176\177"] = "p", --U+1C31
["\225\176\178"] = "r", --U+1C32
["\225\176\179"] = "t", --U+1C33
["\225\176\180"] = "ng", --U+1C34
["\225\176\181"] = "ng", --U+1C35
["\225\176\182"] = "^", --U+1C36
["\225\176\183"] = "", --U+1C37
["\225\176\187"] = "[ta-rol]", --U+1C38
["\225\176\188"] = "[nyet thyoom ta-rol]", --U+1C39
["\225\176\189"] = "[cer-wa]", --U+1C3A
["\225\176\190"] = "[tshook cer-wa]", --U+1C3B
["\225\176\191"] = "[tshook]", --U+1C3C
["\225\177\128"] = "0", --U+1C3D
["\225\177\129"] = "1", --U+1C3E
["\225\177\130"] = "2", --U+1C3F
["\225\177\131"] = "3", --U+1C40
["\225\177\132"] = "4", --U+1C41
["\225\177\133"] = "5", --U+1C42
["\225\177\134"] = "6", --U+1C43
["\225\177\135"] = "7", --U+1C44
["\225\177\136"] = "8", --U+1C45
["\225\177\137"] = "9", --U+1C46
["\225\177\141"] = "tt", --U+1C4D
["\225\177\142"] = "tth", --U+1C4E
["\225\177\143"] = "dd", --U+1C4F
}
function export.tr(text, lang, sc)
local nukta = "\225\176\183"
local initials = "([\225\176\128-\225\176\163\225\177\141-\225\177\143])"
local medials = "([\225\176\164-\225\176\165]?)"
local vowels_after = "([\225\176\166\225\176\170-\225\176\172\225\176\167-\225\176\169])"
local finals_after = "([\225\176\173-\225\176\182]?)"
local others = "[\225\176\184-\225\177\134]"
local im = initials..medials
local imf = initials..medials..finals_after
local imvf = initials..medials..vowels_after..finals_after
text = mw.ustring.gsub(text, nukta, "")
text = mw.ustring.gsub(text, imvf, function(i,m,v,f)
return conv[i] .. conv[m] .. conv[v] .. conv[f]
end)
text = mw.ustring.gsub(text, imf, function(i,m,f)
return conv[i] .. conv[m] .. "a" .. conv[f]
end)
text = mw.ustring.gsub(text, im, function(i,m)
return conv[i] .. conv[m] .. "a"
end)
text = mw.ustring.gsub(text, others, conv)
return text
end
return export