Module:mga-sortkey
Appearance
- The following documentation is located at Module:mga-sortkey/documentation. [edit] Categories were auto-generated by Module:module categorization. [edit]
- Useful links: subpage list • links • transclusions • testcases • sandbox
This module will sort Middle Irish language text.
The module should preferably not be called directly from templates or other modules.
To use it from a template, use {{sortkey}}.
Within a module, use Module:languages#Language:makeSortKey.
For testcases, see Module:mga-sortkey/testcases.
Functions
makeSortKey(text, lang, sc)- Generates a sortkey for a given piece of
textwritten in the script specified by the codesc, and language specified by the codelang. - When the sort fails, returns
nil.
local export = {}
local u = mw.ustring.char
local remove_diacritics = u(0x0301) .. "-"
local oneChar = {
["æ"] = "e"
}
function export.makeSortKey(text, lang, sc)
text = mw.ustring.gsub(mw.ustring.lower(mw.ustring.toNFD(text)), "^h", "")
return mw.ustring.upper(mw.ustring.toNFC(mw.ustring.gsub(mw.ustring.toNFD(mw.ustring.gsub(text, ".", oneChar)), "[" .. remove_diacritics .. "]", "")))
end
return export