มอดูล:hmd-translit
- The following documentation is generated by Module:documentation/functions/translit. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate ภาษาA-Hmao 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:hmd-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 mapping1 = {
["𖽃"] = "a", ["𖼖"] = "l", ["𖼀"] = "b", ["𖼊"] = "d", ["𖼷"] = "z",
["𖼇"] = "f", ["𖼦"] = "h", ["𖼯"] = "zh", ["𖼞"] = "g", ["𖼎"] = "dr",
["𖼐"] = "n", ["𖼄"] = "m", ["𖼓"] = "w", ["𖼈"] = "v", ["𖼡"] = "ġ",
["𖼽"] = "j", ["𖼺"] = "s", ["𖼻"] = "z", ["𖼚"] = "dl", ["𖼘"] = "hl",
["𖼣"] = "ng", ["𖼨"] = "ḡ", ["𖼳"] = "sh", ["𖼵"] = "r", ["𖼁"] = "ba",
}
local digraph = {
["𖼀𖽑"] = "p", ["𖼊𖽑"] = "t", ["𖼷𖽑"] = "c", ["𖼯𖽑"] = "ch", ["𖼞𖽑"] = "k",
["𖼎𖽑"] = "tr", ["𖽑𖼐"] = "hn", ["𖽑𖼄"] = "hm", ["𖼡𖽑"] = "q", ["𖼚𖽑"] = "tl",
["𖽑𖼣"] = "hng", ["𖼨𖽑"] = "x",
}
local tetragraph = {
["𖼐𖼀"] = "nb", ["𖼐𖼀𖽑"] = "np", ["𖼐𖼷"] = "nz", ["𖼐𖼷𖽑"] = "nc", ["𖼐𖼯"] = "nzh",
["C𖼯𖽑"] = "nch", ["𖼐𖼞"] = "ngg", ["𖼐𖼞𖽑"] = "nk", ["𖼐𖼊"] = "nd", ["𖼐𖼊𖽑"] = "nt",
["𖼐𖼎"] = "ndr", ["𖼐𖼎𖽑"] = "ntr", ["C𖼡"] = "nġ", ["C𖼡𖽑"] = "nq", ["C𖼚"] = "ndl", ["C𖼚𖽑"] = "ntl",
}
local vowel_table = {
["𖽔"] = "a", ["𖽡"] = "i", ["𖽙"] = "o", ["𖽪"] = "u", ["𖽳"] = "e", ["𖽜"] = "w", ["𖽹"] = "ai", ["𖽻"] = "ao",
["𖽘"] = "aw", ["𖽠"] = "eu", ["𖽱"] = "ü", ["𖽢"] = "ia", ["𖽡𖽙"] = "io", ["𖽨"] = "iu", ["𖽡𖽳"] = "ie", ["𖽡𖽜"] = "iw",
["𖽡𖽹"] = "iai", ["𖽡𖽻"] = "iao", ["𖽤"] = "iaw", ["𖽡𖽠"] = "ieu",
}
function export.tr(text, lang, sc)
local str_gsub = string.gsub
local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"
-- Convert capital to lowercase palochka.
text = str_gsub(text, mw.ustring.char(0x4C0), mw.ustring.char(0x4CF))
for digraph, replacement in pairs(digraph) do
text = str_gsub(text, digraph, replacement)
end
for tetragraph, replacement in pairs(tetragraph) do
text = str_gsub(text, tetragraph, replacement)
end
text = str_gsub(text, UTF8_char, mapping1)
return text
end
return export