This module will transliterate Udmurt language text per WT:UDM 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:udm-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by the code sc
, and language specified by the code lang
.nil
.local export = {}
local tab = {
="A", ="B", ="V", ="G", ="D", ="E", ="O", ="Ž", ="Dž", ="Z", ="Dź", ="I", ="I", ="J",
="K", ="L", ="M", ="N", ="O", ="Ö", ="P", ="R", ="S", ="T", ="U", ="F",
="X", ="C", ="Ć", ="Č", ="Š", ="Šč", ="", ="Y", ="", ="E", ="U", ="A",
='a', ='b', ='v', ='g', ='d', ='e', ='o', ='ž', ='dž', ='z', ='dź', ='i', ='i', ='j',
='k', ='l', ='m', ='n', ='o', ='ö', ='p', ='r', ='s', ='t', ='u', ='f',
='x', ='c', ='ć', ='č', ='š', ='šč', ='', ='y', ='', ='e', ='u', ='a',
-- Beserman
='Å', ='å', ='W', ='w',
}
function export.tr(text, lang, sc)
local language = lang
-- Ё needs converting if is decomposed
text = text:gsub("ё","ё"):gsub("Ё","Ё")
-- soft consonants
text = mw.ustring.gsub(text, "()()", "%1Q%2")
if lang ~= "udm" then
text = mw.ustring.gsub(text, "()()", "%1Q%2")
end
-- soft vowels after a vowel or at the beginning of a word become j-
text = mw.ustring.gsub(text, "(?)()", "%1j%2")
text = mw.ustring.gsub(text, "^()", "J%1")
text = mw.ustring.gsub(text, "^()", "j%1")
-- palatalisation
text = mw.ustring.gsub(text, "ДQ", "Ď")
text = mw.ustring.gsub(text, "дQ", "ď")
text = mw.ustring.gsub(text, "ЗQ", "Ź")
text = mw.ustring.gsub(text, "зQ", "ź")
text = mw.ustring.gsub(text, "ЛQ", "Ľ")
text = mw.ustring.gsub(text, "лQ", "ľ")
text = mw.ustring.gsub(text, "НQ", "Ń")
text = mw.ustring.gsub(text, "нQ", "ń")
text = mw.ustring.gsub(text, "СQ", "Ś")
text = mw.ustring.gsub(text, "сQ", "ś")
text = mw.ustring.gsub(text, "ТQ", "Ť")
text = mw.ustring.gsub(text, "тQ", "ť")
text = mw.ustring.gsub(text, "Q", "ʹ")
return (mw.ustring.gsub(text,'.',tab))
end
return export