Jump to content

Module:Sah-translit

Frae Wikipedia, the free beuk o knawledge
--[[
Transliteration for Yakut (Sakha).
]]
local export = {}

local tab = {
    ["А"]='A', ["а"]='a', ["Б"]='B', ["б"]='b', ["Г"]='G', ["г"]='g', ["Ҕ"]='Ğ', ["ҕ"]='ğ',
    ["Д"]='D', ["д"]='d', ["И"]='İ', ["и"]='i', ["Й"]='Y', ["й"]='y', ["К"]='K', ["к"]='k',
    ["Л"]='L', ["л"]='l', ["М"]='M', ["м"]='m', ["Н"]='N', ["н"]='n', ["Ҥ"]='Ŋ', ["ҥ"]='ŋ',
    ["О"]='O', ["о"]='o', ["Ө"]='Ö', ["ө"]='ö', ["П"]='P', ["п"]='p', ["Р"]='R', ["р"]='r',
    ["С"]='S', ["с"]='s', ["Һ"]='H', ["һ"]='h', ["Т"]='T', ["т"]='t', ["У"]='U', ["у"]='u',
    ["Ү"]='Ü', ["ү"]='ü', ["Х"]='X', ["х"]='x', ["Ч"]='Ç', ["ч"]='ç', ["Ш"]='Ş', ["ш"]='ş',
    ["Ы"]='I', ["ы"]='ı', ["Э"]='E', ["э"]='e',
    -- non-native letters
    ["В"]='V', ["в"]='v', ["Е"]='E', ["е"]='e', ["Ё"]='Yo', ["ё"]='yo', ["Ж"]='J', ["ж"]='j',
    ["З"]='Z', ["з"]='z', ["Ф"]='F', ["ф"]='f', ["Ц"]='Ts', ["ц"]='ts', ["Щ"]='Şç', ["щ"]='şç',
    ['Ъ']='ʺ', ['ъ']='ʺ', ["Ь"]="’", ["ь"]="’", ["Ю"]='Yu', ["ю"]='yu', ["Я"]='Ya', ["я"]='ya',
}
 
function export.tr(word)
    if type(word) == 'table' then -- called directly from a template
        word = word.args[1]
    end
 
    word = mw.ustring.gsub(word, 'Дь', 'C')
    word = mw.ustring.gsub(word, 'дь', 'c')
    word = mw.ustring.gsub(word, 'Нь', 'Ń')
    word = mw.ustring.gsub(word, 'нь', 'ń')
 
    -- е after a vowel or at the beginning of a word becomes ye
    word = mw.ustring.gsub(word, "([АОӨУҮЫЕЯЁЮИЕЪЬаоөуүыэяёюиеъь%A][́̀]?)е","%1je")
    word = mw.ustring.gsub(word, "^Е","Ye")
    word = mw.ustring.gsub(word, "^е","ye")
    word = mw.ustring.gsub(word, "([^Ѐ-ӿ])Е","%1Ye")
    word = mw.ustring.gsub(word, "([^Ѐ-ӿ])е","%1ye")
 
    return (mw.ustring.gsub(word,'.',tab))
end

return export