Module:huz-translit
Jump to navigation
Jump to search
- The following documentation is located at Module:huz-translit/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will transliterate Hunzib language text per WT:HUZ TR.
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:huz-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 u = require("Module:string/char")
local export = {}
local mapping1 = {
["п"] = "p", ["б"] = "b",
["т"] = "t", ["д"] = "d",
["к"] = "k", ["г"] = "g",
["ц"] = "c", ["ч"] = "č",
["с"] = "s", ["з"] = "z", ["ш"] = "š", ["ж"] = "ž", ["х"] = "x",
["м"] = "m", ["н"] = "n",
["р"] = "r", ["л"] = "l",
["в"] = "v", ["й"] = "y",
["и"] = "i", ["е"] = "e", ["э"] = "e", ["а"] = "a", ["о"] = "o", ["у"] = "u", ["ы"] = "ɨ", ["ә"] = "ə",
["ӣ"] = "ī", ["ā"] = "ā", ["ō"] = "ō", ["ӯ"] = "ū", ["а̇"] = "å", ["а̄̇"] = "ā̊",
["ъ"] = "ʾ", ["ᵸ"] = "̃", ["̇"] = "̊",
}
local digraph = {
["пӏ"] = "ṗ", ["тӏ"] = "ṭ", ["кӏ"] = "ḳ", ["къ"] = "q̇",
["цӏ"] = "c̣", ["лӏ"] = "ƛ", ["кь"] = "ƛ̣", ["чӏ"] = "č̣", ["хъ"] = "q",
["лъ"] = "λ", ["гъ"] = "ǧ", ["хӏ"] = "ḥ", ["гӏ"] = "a̯", ["гь"] = "h",
["а̇ᵸ"] = "å̃", ["а̄̇ᵸ"] = "ā̊̃", ["аᵸ"] = "ã", ["еᵸ"] = "ẽ", ["иᵸ"] = "ĩ", ["оᵸ"] = "õ", ["уᵸ"] = "ũ", ["ыᵸ"] = "ɨ̃", ["әᵸ"] = "ə̃",
}
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, u(0x4C0), u(0x4CF))
for digraph, replacement in pairs(digraph) do
text = str_gsub(text, digraph, replacement)
end
text = str_gsub(text, UTF8_char, mapping1)
return text
end
return export