Wikiup:Lua/Modul/ISO15924/en
aus Wikipedia, der freien Enzyklopädie
< Wikiup:Lua | Modul | ISO15924
Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
ISO15924
– script system according to ISO 15924 and usage in text.
Functions for templates
- getLanguageScript
- Retrieve primary script system code for a language
1
– language code according to ISO 639
- Result: string with script code according to ISO 15924 or
Latn
- isRTL
- Does this code belong to a script written from right to left?
- Result: not empty if right to left
- isScript
- Are all characters of text belonging to a particular script, or neutral?
1
– script code according to ISO 159242
– text
- Result: not empty if matching particular script
- isTrans
- Does a transcription system match a particular script?
- Result: not empty if matching particular transcription system
- scriptName
- Name of a script, hopefully linking on an explaining article
1
– script code according to ISO 159242
– (optional) proprietary additional informationlang
– (optional) language code for result, default: language of hosting wiki, otherwise English
- Result: empty if invalid or currently unknown
- showScript
- Retrieve script code of first text character
1
– text- character itself;
Ω
→Grek
- Hexcode;
U+03A9
→Grek
- character itself;
- Result: empty if invalid, else script code
- showScripts
- Assign the codepoint and script code to every text character
1
– text
- Result: text character by character, each with codepoint and script code
- failsafe
- Version ID (local):
2020-03-10
- Optional parameter:
1
– Minimum version orwikidata
or~
{{#invoke:ISO15924|failsafe}}
yields2020-03-10
- With a parameter as ISO date it is compared whether the current module satisfies this version or later.
{{#invoke:ISO15924|failsafe|2001-01-01}}
returns: »2020-03-10
«{{#invoke:ISO15924|failsafe|2099-01-01}}
returns: »« – (empty), if minimal version condition not matched
- If keyword is
wikidata
, result is version ID registered on Wikidata (2020-03-10
) or local if not found there. - If keyword is
~
, result is empty if local and Wikidata version are the same: (2020-03-10
).
- 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)
A test page illustrates results on input values.
Survey tables
Survey tables for wikitext pages.
Functions for Lua modules (API)
All functions described above can be used by other modules:
local lucky, ISO15924 = pcall( require, "Module:ISO15924" )
if type( ISO15924 ) == "table" then
ISO15924 = ISO15924.ISO15924()
else
-- In the event of errors, ISO15924 is an error message.
return "<span class=\"error\">" .. ISO15924 .. "</span>"
end
Subsequently there are available:
- ISO15924.getLanguageScript( ask )
- Retrieve primary script system code for a language
ask
– language code according to ISO 639
- returns: string with script code according to ISO 15924 or
Latn
- ISO15924.isRTL( ask )
- Does this code belong to a script written from right to left?
- returns: boolean
- ISO15924.isScript( assume, analyse )
- Are all characters of text belonging to a particular script, or neutral?
assume
– script code according to ISO 15924analyse
– text as string or codepoint or table of single characters
- returns: boolean and table
- matching
- table of single characters in
analyse
- ISO15924.isTrans( ask, assign, about )
- Does a transcription system match a particular script?
- returns: boolean
- ISO15924.scriptName( assigned, alien, add )
- Name of a script, hopefully linking on an explaining article
assigned
– script code according to ISO 15924alien
– (optional) proprietary additional informationadd
– (optional) language code for result, default: language of hosting wiki, otherwise English
- returns: string, empty if invalid or currently unknown
- ISO15924.showScript( analyse )
- Retrieve script code of first text character
analyse
– text as string or codepoint or table of single characters
- returns: script code, or false
- ISO15924.showScripts( analyse )
- Assign the codepoint and script code to every text character
analyse
– text as string or codepoint or table of single characters
- returns: string, character by character, each with codepoint and script code
- ISO15924.testScripts( assume, analyse )
- How many text characters of text are belonging to a particular script?
assume
– script code according to ISO 15924analyse
– text as string or codepoint or table of single characters
- returns: two numbers
- number of explicitly matching characters
- number of violating characters
- ISO15924.failsafe( atleast )
- Versioning interface
- atleast
optional
nil or minimum version orwikidata
or~
for synchronisation
- atleast
- returns: Version ID as string or
false
Internal sub modules
loadData
The global data will be converted each into Lua table, which is available by mw.loadData()
once per rendered page.
There are two access modes:
- Module:ISO15924/commons
- Live generation from global data on Commons; might need a purge after change.
- Module:ISO15924/codes
- Same information, but frozen snapshot.
- Better performance.
Data structure:
- Payload are components with one table each as assignment:
cjk
– boolean, if CJKiso639script
– sequence table with any number of string items – script systems usually matching this languagertl
– boolean, if right to lefttrans
– sequence table with any number of string items – transcription systems dedicated to script or languageunicodes
– sequence table with Unicode ranges applicable for a script system (table of two numbers as codepoints)reverse
– sequence table with two numbers as codepoints and table with any number of string items – script systems
failsafe
– string with version IDlast
– boolean,true
if static Lua code updated with Wikidata
/maintain
Internal – functions for generation of derived data and maintainance etc.
Global data
- commons:Data:ISO15924.tab
- List of individual code tables on commons:Data:
- commons:Data:ISO15924/cjk.tab
- Does this code belong to CJK?
- Available as loadData
.cjk
- commons:Data:ISO15924/iso639script.tab
- In which script systems is this language usually written?
- Available as loadData
.iso639script
- commons:Data:ISO15924/rtl.tab
- Is this script system written from right to left?
- Available as loadData
.rtl
- commons:Data:ISO15924/trans.tab
- Transcription system dedicated to script or language
- Available as loadData
.trans
- commons:Data:ISO15924/unicodes.tab
- Unicode ranges applicable for a script system
- Available as loadData
.unicodes
- commons:Data:ISO15924/reverse.tab
- Mapping of all Unicode ranges to referred script system
- Available as loadData
.reverse
- Generated by /maintain
These data is available by central access and maintenance to all Wikis.
Project configuration
By Module:ISO15924/config the local project may be configured optionally.
Returns table with components:
- live
true
– Use commons → commons:Data:- Default: Snapshot
- tmplLang
- Pattern for templates in local project to show a particular language name and link to explaining page
- table with components:
- Examples:
- enwiki →
{ namePat = "lang-%s" }
- dewiki →
{ namePat = "%sS" }
- enwiki →
Installation on other WMF projects
Follow the steps:
- Copy main module
Module:ISO15924
into your project.- If possible keep the name
ISO15924
. - 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:Q71584769.
- Copy at least one of the following sub modules, and keep the chosen root name:
- If
/commons
is chosen, in project configurationlive
switch is needed.- Module:ISO15924/config should keep the chosen root name.
- If script names shall be shown
/translate
needs to be copied and extended to local language.- Translations might be passed back to upstream (here).
/pages
are needed for linking with articles.- In future Wikidata lexems and items may be exploited as fallback.
- If wikitext pages with survey tables are desired
/table
is necessary. - Ready.
- Consider translation of doc page.
Usage
General library; no limitations.
Dependencies
No other than internal sub modules.