Module:bnt-pro-sortkey: Difference between revisions
Jump to navigation
Jump to search
m Protected "Module:bnt-pro-sortkey": Highly visible template/module ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite)) |
m 1 revision imported |
(No difference)
| |
Latest revision as of 12:00, 21 April 2026
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local u = mw.ustring.char
local a, b = u(0xF000), u(0xF001)
local remove_diacritics = u(0x0300) .. u(0x0301) -- grave, acute
local oneChar = {
["ɪ"] = "i" .. a, ["ì"] = "i" .. b, ["í"] = "i" .. b, ["ʊ"] = "u" .. a, ["ù"] = "u" .. b, ["ú"] = "u" .. b
}
function export.makeSortKey(text, lang, sc)
return mw.ustring.upper(mw.ustring.toNFC(mw.ustring.gsub(mw.ustring.toNFD(mw.ustring.gsub(mw.ustring.lower(text), ".", oneChar)), "[" .. remove_diacritics .. "]", ""))) -- decompose, remove appropriate diacritics, then recompose again
end
return export