local export = {}
local u = mw.ustring.char
local MACRON = u(0x0304)
local DOTABOVE = u(0x0307)
local tab = {
='A', ='a', ='B', ='ʙ', ='W', ='w',
='E', ='e', ='Jo', ='jo', ='G', ='g',
='D', ='d', ='I', ='i', ='Ī', ='ī',
='J', ='j', ='K', ='k', ='L', ='l',
='M', ='m', ='N', ='n', ='Ŋ', ='ŋ',
='O', ='o', ='Ö', ='ö', ='Ö', ='ö',
='P', ='p', ='R', ='r', ='S', ='s',
='T', ='t', ='U', ='u', ='Ū', ='ū',
='F', ='f', ='H', ='h', ='C', ='c',
='I', ='i', ='Ə', ='ə', ='Ju', ='ju',
='Ẹ', ='ẹ', -- Not present in the original latinisation
-- non-native letters
='Z', ='z', ='Z', ='z',
='C', ='c', ='S', ='s', ='S', ='s',
='ʺ', ='ʺ', ="’", ="’",
-- non-standard letters
='Γ', ='γ', ='Ŋ', ='ŋ', ='Ü', ='ü',
='Ḥ', ='ḥ', ='Q', ='q'
}
local iotatedTranslit = {
= "je",
= "ja",
= "ji",
= "jī",
= "Je",
= "Ja",
}
local replacements = {
{ "Ё", 'Jo' },
{ "ё", 'jo' },
{ "Ӫ", 'Jö' },
{ "ӫ", 'jö' },
{ "Ю", 'Ju' },
{ "ю", 'ju' },
-- Unfortunately the Cyrillic alphabet doesn't distinguish between ʒe and ʒə
{ "Де", 'Ʒe' },
{ "де", 'ʒe' },
{ "Не", 'Ņe' },
{ "не", 'ņe' },
{ "Ди", 'Ʒi' },
{ "ди", 'ʒi' },
{ "Ни", 'Ņi' },
{ "ни", 'ņi' },
{ "Дя", 'Ʒa' },
{ "дя", 'ʒa' },
{ "Ня", 'Ņa' },
{ "ня", 'ņa' },
{ "Дj", 'Ʒ' },
{ "дj", 'ʒ' },
{ "Нj", 'Ņ' },
{ "нj", 'ņ' },
-- The following is non-standard but supposedly used in non-standard spelling and dialect forms
{ "Дь", 'Ʒ' },
{ "дь", 'ʒ' },
{ "Нь", 'Ņ' },
{ "нь", 'ņ' },
{ "Нг", 'Ŋ' },
{ "нг", 'ŋ' },
}
function export.tr(text, lang, sc)
local ugsub, str_gsub = mw.ustring.gsub, string.gsub
local UTF8char = '*'
for i, replacement in ipairs(replacements) do
text = str_gsub(text, unpack(replacement))
end
-- е after a vowel or at the beginning of a word becomes ye
-- Again, the Cyrillic alphabet doesn't distinguish between je and jə
text = ugsub(text,
"(?)()",
function(preceding, iotated)
return preceding .. iotatedTranslit
end)
text = ugsub(text, "^", iotatedTranslit)
text = ugsub(text, "()()",
function(preceding, iotated)
return preceding .. iotatedTranslit
end)
text = str_gsub(text, UTF8char, tab)
return text
end
return export