Wikipedia:Lua/Modul/Sort/en
Erscheinungsbild
Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Weiterleitung der Diskussionsseite fehlt
Sort
– module with auxilary functions to create sortable keys.
Functions for templates
[Am Gwëntext werkeln]- All functions evaluate the first parameter as term to be sorted.
- If there is no first parameter provided by
#invoke
the first parameter of surrounding template transclusion will be used.
- If there is no first parameter provided by
- Optional parameters of
#invoke
specify input and result format and further capabilities.
Return value is always the sort key.
Tlatin
[Am Gwëntext werkeln]Alphanumeric terms in latin based scripts are reduced to basic characters of ASCII set.
- Optional parameters
-
- v
- Variant
- Default: ISO (simplify all diacritic characters; ligatures of two letters)
DIN5007m2
(DIN 5007 Variante 2)
- Various typografic codes for spaces, horizontal dashes and invisible characters are reduced to ASCII.
- Multiple whitespace is reduced to single space.
Casing (upcased/downcased) will remain; that can be eliminated easily from result.
failsafe
[Am Gwëntext werkeln]- Purpose
- Version ID (local):
2019-10-29
- Optional parameter:
1
– Minimum version orwikidata
{{#invoke:Sort|failsafe}}
yields2019-10-29
- With a parameter as ISO date it is compared whether the current module satisfies this version or later.
{{#invoke:Sort|failsafe|2001-01-01}}
returns: »2019-10-29
«{{#invoke:Sort|failsafe|2099-01-01}}
returns: »« – (empty), if minimal version condition not matched
- If keyword is
wikidata
, result is version ID registered on Wikidata (2024-06-14
) or local if not found there. - If keyword is
~
, result is empty if local and Wikidata version are the same: (2024-06-14
).
- Returns:
- Empty, if minimal version condition not matched, or
~
and local version is synchronized. - Version ID if no parameter, or if
wikidata
, or local if not found there, or not synchronized.
- Empty, if minimal version condition not matched, or
Examples (test page)
[Am Gwëntext werkeln]A test page illustrates results on input formats.
Date and time
[Am Gwëntext werkeln]That is implemented by the module DateTime.
Functions for Lua modules (API)
[Am Gwëntext werkeln]All functions described above can be used by other modules:
local lucky, Sort = pcall( require, "Module:Sort" )
if type( Sort ) == "table" then
Sort = Sort.Sort()
else
-- In the event of errors, Sort is an error message.
return "<span class='error'>" .. Sort .. "</span>"
end
- Sort.lex( adjust, apply, adapt )
- Similar to Tlatin.
- adjust
- term (string)
- mandatory
- apply
- base script (string)
"latin"
"cyrillic"
"greek"
"uni"
- currently
latin
available only - adapt
- variant (string, optional)
"DIN5007m2"
- Sort.failsafe( atleast )
- Versioning interface similar to failsafe
- atleast
- optional
- nil or minimum version or
wikidata
or~
for synchronisation
- returns: Version ID as string or
false
Installation on other WMF projects
[Am Gwëntext werkeln]Follow the steps:
- Copy main module
Module:Sort
into your project.- If possible keep the name
Sort
. - If another name is required due to conflict or naming convention or non-latin script then choose a different one.
- If possible keep the name
- Register this module at d:Q24205172.
- Copy desired sub modules, and keep the chosen root name.
- Ready.
- Consider translation of doc page.
Usage
[Am Gwëntext werkeln]General library; no limitations.
Dependencies
[Am Gwëntext werkeln]No other than sub modules.
Sub modules
[Am Gwëntext werkeln]- Module:Sort/latin containing the collation table for latin based scripts.
- Module:Sort/latinDIN5007m2 containing the collation table for DIN 5007 Variante 2.
- Module:Sort/latinAT containing the collation table specific for Austrian.
- Module:Sort/latinCS containing the collation table specific for Czechoslovakian.
- Module:Sort/latinDA containing the collation table specific for Danish.
- Module:Sort/latinScand containing a collation table specific for scandinavian languages.
- Module:Sort/currency containing a collation table for currency symbols.
- Module:Sort/utf8max2bytes containing a collation table only reducing to 2 Bytes in UTF-8.
- Module:Sort/unquote supports discarding of quotation marks.
Envisioned
[Am Gwëntext werkeln]- Module:Sort/cyrillic – containing collation table for cyrillic based scripts (Ukrainian etc.).
- Module:Sort/greek – containing collation table for greek scripts (polytonic).
- Module:Sort/uni – containing collation table for all (letter based?) script systems.
Internationalisation
[Am Gwëntext werkeln]Not necessary.