This module will transliterate Southern Altai and Northern Altai text per WT:ALT TR and WT:ATV 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:Altai-translit/testcases.
tr(text, lang, sc)
text
written in the script specified by sc
, and language specified by lang
. When the transliteration fails, returns nil
.local export = {}
local tab = {
="A", ="B", ="V", ="G", ="D", ="E", ="Yo", ="Ž", ="Z", ="I", ="Y", ="J̌", ="J̌]",
="K", ="L", ="M", ="N", ="Ŋ", ="O", ="Ö", ="Ö]", ="P", ="R", ="S", ="T",
="U", ="Ü", ="F", ="H", ="C", ="Č", ="Š", ="Šč", ="ʺ", ="Ï", ="ʹ",
="E", ="Yu", ="Ya",
='a', ='b', ='v', ='g', ='d', ='e', ='yo', ='ž', ='z', ='i', ='y', ="ǰ", ="ǰ]",
='k', ='l', ='m', ='n', ='ŋ', ='o', ='ö', ='ö]', ='p', ='r', ='s', ='t',
='u', ='ü', ='f',
='h', ='c', ='č', ='š', ='šč', ='ʺ', ='ï', ='ʹ', ='e', ='yu', ='ya',
}
local iotated = {
= "Ye",
= "ye",
}
function export.tr(text, lang, sc)
local ugsub = mw.ustring.gsub
-- Ё needs to be composed if is decomposed (e + combining diaeresis).
-- However, this cannot happen in wikitext, only in Lua modules.
text = mw.ustring.toNFC(text)
-- е after a vowel or at the beginning of a word becomes ye
-- Note that according to modern Altai orthography ее (instead of ээ) is occationally used for long r
text = ugsub(text, "(?)е", "%1ye")
--text = mw.ustring.gsub(text, "(?)е", "%1ye")
text = ugsub(text, "^", iotated)
text = ugsub(text, "()()", function(a, b)
return a .. iotated
end)
return (ugsub(text, '.', tab))
end
return export