| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English | Modul: | Dokumentation | |||
ISO3166 – Module for conversion of territory code from ISO 3166 into one of the most current ones.
Historic countries are difficult to retrieve, since code assignment started about 1970 and they were partially reused for other targets later. Division of states does not point to current country, but unification. Only codes known to or reserved by ISO are covered, while other organisations like IOC often collide.
1 – code to be converted (mandatory)2 – requested format of result
A2 or A3 or NUM or A4A33 – redirect into other territory
1 – historic state0 – current country2019-10-141 – Minimum version or wikidata or ~{{#invoke:ISO3166|failsafe}} yields 2019-10-14{{#invoke:ISO3166|failsafe|2001-01-01}} returns: »2019-10-14«{{#invoke:ISO3166|failsafe|2099-01-01}} returns: »« – (empty), if minimal version condition not matchedwikidata, result is version ID registered on Wikidata (2019-10-14) or local if not found there.~, result is empty if local and Wikidata version are the same: ().~ and local version is synchronized.wikidata, or local if not found there, or not synchronized.There are tests available to illustrate this in practice.
All of the above functions can be called from other Lua modules. Use require(); the following code checks for errors loading it:
local lucky, ISO3166 = pcall( require, "Module:ISO3166" )
if type( ISO3166 ) == "table" then
ISO3166 = ISO3166.ISO3166()
else
-- In the event of errors, ISO3166 is an error message.
return "<span class=\"error\">" .. ISO3166 .. "</span>"
end
Then there is available:
A3falsefalse if not recognizedtrue for abort by error()
false – empty tablewikidata or ~ for synchronisationfalseGlobal data will be converted into a single mw.loadData() table once per rendered page if needed.
codes – map A2 → space separated sequencereverse – map anything → A2failsafe – serial IDInternal – code used as generator of commons:Data:ISO3166/reverse.tab data.
Supports template invocations:
factory – Test/maintainfailsafeData is centralized and immediately updated, available to all wikis.
When changing an entry in commons:Data:ISO3166/codes.tab updating of commons:Data:ISO3166/reverse.tab is required by Test/maintain.
Follow the steps:
Module:ISO3166 into your project.
ISO3166.This is a general library; use it anywhere.
None.