Difference between revisions 18626557 and 18626558 on frwiktionarylocal 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 = { ["ae"] = "Module:Avst-translit", ["ady"] = "Module:ady-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", ["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) -- list of characters that may occur at the beginning of a word -- TODO: move to [[Module:scripts]] local chars_table = { ["Latn"] = "A-Za-z0-z¡-ɏḀ-ỿ", ["Arab"] = "-ۿݐ-ݿ", ["Armn"] = "Ա-֊", ["Beng"] = "ঁ-৺", ["Cyrl"] = "Ѐ-ӿ", ["Deva"] = "ँ-ॽ", ["Geor"] = "Ⴀ-ჼ", ["Goth"] = "𐌰-𐍊", (contracted; show full) chars_table["ps-Arab"] = chars_table["Arab"] chars_table["sd-Arab"] = chars_table["Arab"] chars_table["tt-Arab"] = chars_table["Arab"] chars_table["ug-Arab"] = chars_table["Arab"] chars_table["ur-Arab"] = chars_table["Arab"] chars_table["Latf"] = chars_table["Latn"] chars_table["Latinx"] = chars_table["Latn"] .. "ƀ-ɏ" chars_table["nv-Latn"] = chars_table["Latn"] .. "ḻṉṟṯ" chars_table["pjt-Latn"] = chars_table["Latn"] -- first try to detect the script based on the native script(s) of the language local scripts = languages[lang].scripts or {} for i, script in ipairs(scripts) do if chars_table[script] and mw.ustring.match(text, "[" .. chars_table[script] .. "]") then return script (contracted; show full) i = i + 1 cat = args[i] end return export.format_categories(categories, lang, sort_key) end return export All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://fr.wiktionary.org/w/index.php?diff=prev&oldid=18626558.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|