Module:Linb-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:Linb-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list โข links โข transclusions โข testcases โข sandbox
This module will transliterate text in the Linear B script. It is used to transliterate Mycenaean Greek.
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:Linb-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 chars = {
["๐"] = "a",
["๐"] = "e",
["๐"] = "i",
["๐"] = "o",
["๐"] = "u",
["๐
"] = "da",
["๐"] = "de",
["๐"] = "di",
["๐"] = "do",
["๐"] = "du",
["๐"] = "ja",
["๐"] = "je",
-- ji not in Unicode
["๐"] = "jo",
["๐"] = "ju",
["๐"] = "ka",
["๐"] = "ke",
["๐"] = "ki",
["๐"] = "ko",
["๐"] = "ku",
["๐"] = "ma",
["๐"] = "me",
["๐"] = "mi",
["๐"] = "mo",
["๐"] = "mu",
["๐"] = "na",
["๐"] = "ne",
["๐"] = "ni",
["๐"] = "no",
["๐"] = "nu",
["๐"] = "pa",
["๐"] = "pe",
["๐ "] = "pi",
["๐ก"] = "po",
["๐ข"] = "pu",
["๐ฃ"] = "qa",
["๐ค"] = "qe",
["๐ฅ"] = "qi",
["๐ฆ"] = "qo",
-- qu not in Unicode
["๐จ"] = "ra",
["๐ฉ"] = "re",
["๐ช"] = "ri",
["๐ซ"] = "ro",
["๐ฌ"] = "ru",
["๐ญ"] = "sa",
["๐ฎ"] = "se",
["๐ฏ"] = "si",
["๐ฐ"] = "so",
["๐ฑ"] = "su",
["๐ฒ"] = "ta",
["๐ณ"] = "te",
["๐ด"] = "ti",
["๐ต"] = "to",
["๐ถ"] = "tu",
["๐ท"] = "wa",
["๐ธ"] = "we",
["๐น"] = "wi",
["๐บ"] = "wo",
-- wu not in Unicode
["๐ผ"] = "za",
["๐ฝ"] = "ze",
-- zi not in Unicode
["๐ฟ"] = "zo",
-- zu not in Unicode
["๐"] = "ha",
["๐"] = "ai",
["๐"] = "au",
["๐"] = "dwe",
["๐"] = "dwo",
["๐
"] = "nwo",
["๐"] = "phu",
["๐"] = "pte",
["๐"] = "rya",
["๐"] = "rai",
["๐"] = "ryo",
["๐"] = "tya",
["๐"] = "twe",
["๐"] = "two",
["๐"] = "*18",
["๐"] = "*19",
["๐"] = "*22",
["๐"] = "*34",
["๐"] = "*47",
["๐"] = "*49",
["๐"] = "*56",
["๐"] = "*63",
["๐"] = "*64",
["๐"] = "*79",
["๐"] = "*82",
["๐"] = "*83",
["๐"] = "*86",
["๐"] = "*89",
-- explicit morpheme boundary
["-"] = "`",
}
function export.tr(text, lang, sc)
local ret = {}
local i = 1
for c in string.gmatch(text, "[%z\1-\127\194-\244][\128-\191]*") do -- UTF-8 character pattern
ret[i] = chars[c] or c
i = i + 1
end
text = string.gsub(table.concat(ret, "-"), "%- %-", " ")
text = string.gsub(text, "%-?`%-?", "-")
return text
end
return export