Wikipedia:Lua/Modul/Sort/en
Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Sort
– module with auxilary functions to create sortable keys.
Functions for templates
[Quelltext bearbeiten]- The sort functions (Tlatin left only) 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
[Quelltext bearbeiten]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.
textOrder
[Quelltext bearbeiten]The value is 1
if the first string is lexical less than second string else empty.
- Mandatory parameters, leading whitespace is significant
-
- 1
- first string
- 2
- second string
failsafe
[Quelltext bearbeiten]Version management
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
- ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
- administrate global updating and linking of module codes via Wikidata.
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
Value | Result | current |
---|---|---|
nothingfalse
|
local version ID | »2024-06-14« |
Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata
|
version ID of global upstream
|
»2024-06-14« |
item
|
ID of the Wikidata item
|
Q24205172
|
~
|
Corresponding version ID locally and registered at Wikidata
|
»« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false , otherwis a non-empty string as described.
|
Examples (test page)
[Quelltext bearbeiten]A test page illustrates results on input formats.
Date and time
[Quelltext bearbeiten]That is implemented by the module DateTime.
Functions for Lua modules (API)
[Quelltext bearbeiten]All functions described above can be used by other modules:
local lucky, Sort = pcall( require, "Module:Sort" )
if type( Sort ) == "table" then
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
Until 2023 Sort = Sort.Sort()
has been recommended for initialization.
Installation on other WMF projects
[Quelltext bearbeiten]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.
- Consider Module:Sort/local adaption to local wiki.
Adaption to local wiki
[Quelltext bearbeiten]Module:Sort/local, if present, permits local configuration.
- simpleDatePattern
- pattern for
#time:
– formatting one particular day - Default:
j M Y
Usage
[Quelltext bearbeiten]General library; no limitations.
Dependencies
[Quelltext bearbeiten]No other than sub modules.
Sub modules
[Quelltext bearbeiten]- 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.
- Module:Sort/local adaption to local wiki.
Envisioned
[Quelltext bearbeiten]- 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
[Quelltext bearbeiten]Not necessary.