Difference between revisions 18626575 and 18626576 on frwiktionary

local m_languages = mw.loadData("Module:languages")
local export = {}

-- transliterate the text, if possible
function export.translit(lang, text)
    -- TODO: the table's information should be moved to [[Module:languages]]
    local translit_modules = {
        ["ab"] = "Module:ab-translit",
        ["ae"] = "Module:Avst-translit",
        ["ady"] = "Module:ady-translit",
        ["kbd"] = "Module:kbd-translit",
        ["ce"] = "Module:ce-translit",
        ["el"] = "Module:el-translit",
        ["ru"] = "Module:ru-translit",
        ["ug"] = "Module:ug-translit",
        ["tg"] = "Module:tg-translit",
        ["os"] = "Module:os-translit",
        ["ka"] = "Module:ka-translit",
        ["oge"] = "Module:oge-translit",
        ["xmf"] = "Module:xmf-translit",
        ["lzz"] = "Module:lzz-translit",
        ["sva"] = "Module:sva-translit",
        ["xcl"] = "Module:xcl-translit",
        ["axm"] = "Module:axm-translit",
        ["hy"] = "Module:hy-translit"
    }
 
    if translit_modules[lang] then
        return require(translit_modules[lang]).tr(text)
    end
end
 
-- Detect the script based on the first alphabetical characters of a string
function export.detect_script(text, lang)
    local m_scripts = mw.loadData("Module:scripts")
    
    local langinfo = m_languages[lang] or error("The language code \"" .. lang .. "\" is not valid.")
    local scFix = false
    
    -- Does this language have more than one script?
(contracted; show full)        i = i + 1
        cat = args[i]
    end
    
    return export.format_categories(categories, lang, sort_key)
end

return export