Difference between revisions 18626576 and 18626577 on frwiktionarylocal m_languages = mw.loadData("Module:languages") local export = {} -- 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.") (contracted; show full) end return langinfo.scripts[1], scFix end -- Format the categories with the appropriate sort key function export.format_categories(categories, lang, sort_key, sort_base) local langinfo = m_languages[lang] or error("The language code \"" .. lang .. "\" is not valid.")⏎ NAMESPACE = NAMESPACE or mw.title.getCurrentTitle().nsText if NAMESPACE == "" or NAMESPACE == "Appendix" then PAGENAME = PAGENAME or mw.title.getCurrentTitle().text SUBPAGENAME = SUBPAGENAME or mw.title.getCurrentTitle().subpageText -- Generate a default language-independent sort key sort_base = mw.ustring.lower(sort_base or SUBPAGENAME) -- Remove initial hyphens and * sort_base = mw.ustring.gsub(sort_base, "^[-־ـ*]+(.)", "%1") -- Remove anything in parentheses, as long as they are either preceded or followed by something sort_base = mw.ustring.gsub(sort_base, "(.)%([^()]+%)", "%1") sort_base = mw.ustring.gsub(sort_base, "%([^()]+%)(.)", "%1") -- If there are language-specific rules to generate the key, use those if langinfo.sort_key then⏎ then local langinfo = m_languages[lang] or error("The language code \"" .. lang .. "\" is not valid.") if langinfo.sort_key then⏎ for i, from in ipairs(langinfo.sort_key.from) do local to = langinfo.sort_key.to[i] or "" sort_base = mw.ustring.gsub(sort_base, from, to) end⏎ end end if sort_key then -- Gather some statistics regarding sort keys if mw.ustring.lower(sort_key) == sort_base then table.insert(categories, "Sort key tracking/redundant") elseif lang and lang ~= "cmn" and lang ~= "ja" and lang ~= "zu" and lang ~= "nan" and lang ~= "yue" then if lang == "ga" or lang == "gv" or lang == "nv" or lang == "roa-jer" or lang == "fr" or lang == "rm" or lang == "prg" or lang == "gd" or lang == "twf" or lang == "en" or lang == "ro" or lang == "egl" or lang == "roa-tar" or lang == (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=18626577.
![]() ![]() 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.
|