Vorlagenprogrammierung Diskussionen Lua Test Unterseiten
Modul Deutsch English

Modul: Dokumentation

ISO15924 – script system according to ISO 15924 and usage in text.

Functions for templates

Bearbeiten
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 15924
  • 2 – text
Result: not empty if matching particular script
isTrans
Does a transcription system match a particular script?
  • 1 – code of a transcription system
  • 2 – script code according to ISO 15924 or language code according to ISO 639
  • site(optional) script code of hosting wiki
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 15924
  • 2(optional) proprietary additional information
  • lang(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+03A9Grek
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 or wikidata or ~
{{#invoke:ISO15924|failsafe}} yields 2020-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: ().
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.

Examples (test page)

Bearbeiten

A test page illustrates results on input values.

Survey tables

Bearbeiten

Survey tables for wikitext pages.

Functions for Lua modules (API)

Bearbeiten

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?
  • ask – language code according to ISO 639 or script code according to ISO 15924
returns: boolean
ISO15924.isScript( assume, analyse )
Are all characters of text belonging to a particular script, or neutral?
  • assume – script code according to ISO 15924
  • analyse – text as string or codepoint or table of single characters
returns: boolean and table
  1. matching
  2. table of single characters in analyse
ISO15924.isTrans( ask, assign, about )
Does a transcription system match a particular script?
  • ask – code of a transcription system
  • assign – script code according to ISO 15924 or language code according to ISO 639
  • about(optional) script code of hosting wiki
returns: boolean
ISO15924.scriptName( assigned, alien, add )
Name of a script, hopefully linking on an explaining article
  • assigned – script code according to ISO 15924
  • alien(optional) proprietary additional information
  • add(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 15924
  • analyse – text as string or codepoint or table of single characters
returns: two numbers
  1. number of explicitly matching characters
  2. number of violating characters
ISO15924.failsafe( atleast )
Versioning interface
  1. atleast
    optional
    nil or minimum version or wikidata or ~ for synchronisation
returns: Version ID as string or false

Internal sub modules

Bearbeiten

loadData

Bearbeiten

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:

  1. Module:ISO15924/commons
    • Live generation from global data on Commons; might need a purge after change.
  2. Module:ISO15924/codes
    • Same information, but frozen snapshot.
    • Better performance.

Data structure:

  • Payload are components with one table each as assignment:
    • cjkboolean, if CJK
    • iso639script – sequence table with any number of string items – script systems usually matching this language
    • rtlboolean, if right to left
    • trans – sequence table with any number of string items – transcription systems dedicated to script or language
    • unicodes – 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
  • failsafestring with version ID
  • lastboolean, true if static Lua code updated with Wikidata

/maintain

Bearbeiten

Internal – functions for generation of derived data and maintainance etc.

Global data

Bearbeiten
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

Bearbeiten

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:
  • title – unique name of template
  • namePatpattern for name of template, with %s for code according to ISO 639
  • param – parameter name, for code according to ISO 639
Examples:
  • enwiki → { namePat = "lang-%s" }
  • dewiki → { namePat = "%sS" }

Installation on other WMF projects

Bearbeiten

Follow the steps:

  1. 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.
  2. Register this module at d:Q71584769.
  3. Copy at least one of the following sub modules, and keep the chosen root name:
  4. If /commons is chosen, in project configuration live switch is needed.
  5. 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.
  6. If wikitext pages with survey tables are desired /table is necessary.
  7. Ready.
  8. Consider translation of doc page.

General library; no limitations.

Dependencies

Bearbeiten

No other than internal sub modules.