มอดูล:fr-sortkey
หน้าตา
- This มอดูล lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local export = {}
local u = mw.ustring.char
local remove_diacritics = u(0x0300) .. "-" .. u(0x0302) .. u(0x0308) .. u(0x030A) .. u(0x0327) .. "'" -- grave, acute, circumflex, diaeresis, ring above, cedilla, apostrophe
local oneChar = {
["æ"] = "ae", ["œ"] = "oe"
}
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