local export = {}
local tt = {
="ü",='Ü', ="t",='T', ="r",='R', ="f",='F',
="yu",='Yu', ="ş",='Ş', ="’",='’', ="ʺ",='ʺ', ="n",='N',
="p",='P', ="y",='Y', ="l",='L', ="z",='Z', ="e",='E',
="g",='G', ="b",='B', ="u",='U', ="s",='S', ="x",='X',
="ç",='Ç', ="şç",='Şç', ="ya",='Ya', ="ı",='I', ="e",='E',
="m",='M', ="o",='O', ="ö",='Ö', ="i",='İ', ="yo",='Yo',
="j",='J', ="k",='K', ="d",='D', ="w",='W', ="ts",='Ts',
="a",='A', ="ñ",='Ñ', ="c",='C', ="h",='H', ="ä",='Ä'
};
function export.tr(text, lang, sc)
text = mw.ustring.gsub(
text,
"(?)()",
function(a,e) return a..(e=='е' and 'ye' or 'Ye') end
)
text:gsub("^Е",'Ye'):gsub("^е",'ye'):gsub("ия$",'iyä') --not last word end handled in code end
-- Deal with dual nature of к, г, transliterated either to "front" variants
-- k/g or "back" variants q/ğ. The back variants occur before hard signs
-- (Ъ/ъ), which then disappear, and also in the vicinity of the back vowels
-- а/о/у/ы/ә (and their capital equivalents А/О/У/Ы/Ә). The code below that
-- handles this appears to say that the sound of word-initial к/г is
-- determined by the following vowel, and the sound of non-word-initial
-- к/г is determined by the preceding vowel. FIXME: Not sure if this is
-- correct.
local t = {='Q',='q',='Ğ',='ğ'}
text = mw.ustring.gsub(text, '()()', function(a,b) return t end)
text = mw.ustring.gsub(
text,
"(%a?)()(.?)",
function(b,c,a)
return b .. (mw.ustring.match(b>'' and b or a,"") and t or tt) .. a
end
)
return (mw.ustring.gsub(mw.ustring.gsub(text, "ия%A",'iyä'), '.', tt))
end
return export