Jump to content

Module:ISO 3166/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Updated number
No edit summary
Line 2: Line 2:
{{High risk|493000+}}
{{High risk|493000+}}


This module returns a country's or subdivision's name from its [[ISO 3166]] code (the <code>name</code> function), or vice versa (<code>code</code>).
This module returns a country's or subdivision's code (alpha-2, alpha-3, numeric) or name (ISO, non-ISO) from [[ISO 3166]] from a varity of inputs (alpha-2, alpha-3, numeric, name, ISO-name, alternative names). The module also removes junk from the input.

==Examples==
==Examples==
===Countries (ISO 3166-1)===
===Countries (ISO 3166-1)===
All three types of [[ISO 3166-1]] codes (alpha-2, alpha-3 and numeric) work as inputs to <code>name</code>, as well as to <code>code</code> (which can therefore also be used to convert between different code types). Use {{para|codetype}} to output alpha-3 or numeric codes in <code>code</code> instead of the default alpha-2 codes.
All three types of [[ISO 3166-1]] codes (alpha-2, alpha-3 and numeric) work as inputs to <code>name</code>, as well as to <code>code</code> (which can therefore also be used to convert between different code types). Use {{para|codetype}} to output alpha-3 or numeric codes in <code>code</code> instead of the default alpha-2 codes.
====Name====
To get the common name use the name function
*{{tnull|&#35;invoke:ISO 3166|name|GB}} &rarr; {{#invoke:ISO 3166|name|GB}}
*{{tnull|&#35;invoke:ISO 3166|name|GB}} &rarr; {{#invoke:ISO 3166|name|GB}}
*{{tnull|&#35;invoke:ISO 3166|name|GBR}} &rarr; {{#invoke:ISO 3166|name|GBR}}
*{{tnull|&#35;invoke:ISO 3166|name|GBR}} &rarr; {{#invoke:ISO 3166|name|GBR}}
*{{tnull|&#35;invoke:ISO 3166|name|826}} &rarr; {{#invoke:ISO 3166|name|826}}
*{{tnull|&#35;invoke:ISO 3166|name|826}} &rarr; {{#invoke:ISO 3166|name|826}}
====ISO Name====
To get the common name use the name function with isoname = yes
*{{tnull|&#35;invoke:ISO 3166|name|GB|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|GB|isoname=yes}}
*{{tnull|&#35;invoke:ISO 3166|name|GBR|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|GBR|isoname=yes}}
*{{tnull|&#35;invoke:ISO 3166|name|826|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|826|isoname=yes}}
====Alpha-2====
To get the alpha 2 code use the code function
*{{tnull|&#35;invoke:ISO 3166|code|826}} &rarr; {{#invoke:ISO 3166|code|826}}
*{{tnull|&#35;invoke:ISO 3166|code|826}} &rarr; {{#invoke:ISO 3166|code|826}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom}} &rarr; {{#invoke:ISO 3166|code|United Kingdom}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom}} &rarr; {{#invoke:ISO 3166|code|United Kingdom}}
*{{tnull|&#35;invoke:ISO 3166|code|UK}} &rarr; {{#invoke:ISO 3166|code|UK}}
*{{tnull|&#35;invoke:ISO 3166|code|UK}} &rarr; {{#invoke:ISO 3166|code|UK}}
====Alpha-3====
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom|codetype{{=}}3}} &rarr; {{#invoke:ISO 3166|code|United Kingdom|codetype=3}}
To get the alpha 3 code use the code function with codetype = 3
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|code|United Kingdom|codetype=alpha3}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|code|United Kingdom|codetype=alpha3}}
*{{tnull|&#35;invoke:ISO 3166|name|GB|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|name|GB|codetype=alpha3}}
*{{tnull|&#35;invoke:ISO 3166|name|GBR|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|name|GBR|codetype=alpha3}}
*{{tnull|&#35;invoke:ISO 3166|name|826|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|name|826|codetype=alpha3}}
*{{tnull|&#35;invoke:ISO 3166|code|UK|codetype{{=}}alpha3}} &rarr; {{#invoke:ISO 3166|code|UK|codetype=alpha3}}
====Numeric====
To get the numeric code use the code function with codetype = numeric '''or''' use the numeric function
*{{tnull|&#35;invoke:ISO 3166|numeric|GB}} &rarr; {{#invoke:ISO 3166|numeric|GB}}
*{{tnull|&#35;invoke:ISO 3166|numeric|GB}} &rarr; {{#invoke:ISO 3166|numeric|GB}}
*{{tnull|&#35;invoke:ISO 3166|code|GB|codetype{{=}}numeric}} &rarr; {{#invoke:ISO 3166|code|GB|codetype=numeric}}
*{{tnull|&#35;invoke:ISO 3166|code|GB|codetype{{=}}numeric}} &rarr; {{#invoke:ISO 3166|code|GB|codetype=numeric}}

Set {{para|isoname}} to return the country name as used in the ISO standard as opposed to the common name:
*{{tnull|&#35;invoke:ISO 3166|name|BO}} &rarr; {{#invoke:ISO 3166|name|BO}}
*{{tnull|&#35;invoke:ISO 3166|name|BO|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|BO|isoname=yes}}
*{{tnull|&#35;invoke:ISO 3166|name|GB}} &rarr; {{#invoke:ISO 3166|name|GB}}
*{{tnull|&#35;invoke:ISO 3166|name|GB|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|GB|isoname=yes}}
*{{tnull|&#35;invoke:ISO 3166|name|MO}} &rarr; {{#invoke:ISO 3166|name|MO}}
*{{tnull|&#35;invoke:ISO 3166|name|MO|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|MO|isoname=yes}}

===Subdivisions (ISO 3166-2)===
===Subdivisions (ISO 3166-2)===
Inputs to <code>name</code> must be valid [[ISO 3166-2]] codes, i.e. the country's alpha-2 code for the first part, and up to three alphanumeric characters for the second part. They may be given normally (with a hyphen between the parts), or split between two unnamed parameters. For <code>code</code>, the first parameter is the country name (or any of its three codes, like above), and the second the subdivision name.
Inputs to <code>name</code> must be valid [[ISO 3166-2]] codes, i.e. the country's alpha-2 code for the first part, and up to three alphanumeric characters for the second part. They may be given normally (with a hyphen between the parts), or split between two unnamed parameters. For <code>code</code>, the first parameter is the country name (or any of its three codes, like above), and the second the subdivision name.
====Code (alpha-2)====
*{{tnull|&#35;invoke:ISO 3166|name|GB-ENG}} &rarr; {{#invoke:ISO 3166|name|GB-ENG}}
To get the alpha-2 code of a subdivision use the code function with parameter 1 being the country and parameter 2 being the subdivision
*{{tnull|&#35;invoke:ISO 3166|name|GB|ENG}} &rarr; {{#invoke:ISO 3166|name|GB|ENG}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom|England}} &rarr; {{#invoke:ISO 3166|code|United Kingdom|England}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom|England}} &rarr; {{#invoke:ISO 3166|code|United Kingdom|England}}
*{{tnull|&#35;invoke:ISO 3166|code|GBR|England}} &rarr; {{#invoke:ISO 3166|code|GBR|England}}
*{{tnull|&#35;invoke:ISO 3166|code|GBR|England}} &rarr; {{#invoke:ISO 3166|code|GBR|England}}
*{{tnull|&#35;invoke:ISO 3166|code|GB|England}} &rarr; {{#invoke:ISO 3166|code|GB|England}}
*{{tnull|&#35;invoke:ISO 3166|code|GB|England}} &rarr; {{#invoke:ISO 3166|code|GB|England}}
====Name====
To get the name of a subdivision use the name function with parameter 1 being the country and parameter 2 being the subdivsion '''or''' parameter 1 being the subdivsion code
*{{tnull|&#35;invoke:ISO 3166|name|GB-ENG}} &rarr; {{#invoke:ISO 3166|name|GB-ENG}}
*{{tnull|&#35;invoke:ISO 3166|name|GB|ENG}} &rarr; {{#invoke:ISO 3166|name|GB|ENG}}


{{para|isoname}} works for subnational entities as well; keep in mind that ISO 3166-2 uses (transliterations of) local names that may differ from English ones. Set {{para|lang}} to a [[ISO 639|language code]] to switch between different languages for entities that have multiple ISO names. The default language for multilingual entities can be set on the country's [[Module:ISO 3166/data|data page]].
{{para|isoname}} works for subnational entities as well; keep in mind that ISO 3166-2 uses (transliterations of) local names that may differ from English ones. Set {{para|lang}} to a [[ISO 639|language code]] to switch between different languages for entities that have multiple ISO names. The default language for multilingual entities can be set on the country's [[Module:ISO 3166/data|data page]].

Revision as of 18:38, 16 September 2018

This module returns a country's or subdivision's code (alpha-2, alpha-3, numeric) or name (ISO, non-ISO) from ISO 3166 from a varity of inputs (alpha-2, alpha-3, numeric, name, ISO-name, alternative names). The module also removes junk from the input.

Examples

Countries (ISO 3166-1)

All three types of ISO 3166-1 codes (alpha-2, alpha-3 and numeric) work as inputs to name, as well as to code (which can therefore also be used to convert between different code types). Use |codetype= to output alpha-3 or numeric codes in code instead of the default alpha-2 codes.

Name

To get the common name use the name function

  • {{#invoke:ISO 3166|name|GB}} → United Kingdom
  • {{#invoke:ISO 3166|name|GBR}} → United Kingdom
  • {{#invoke:ISO 3166|name|826}} → United Kingdom

ISO Name

To get the common name use the name function with isoname = yes

  • {{#invoke:ISO 3166|name|GB|isoname=yes}} → United Kingdom of Great Britain and Northern Ireland
  • {{#invoke:ISO 3166|name|GBR|isoname=yes}} → United Kingdom of Great Britain and Northern Ireland
  • {{#invoke:ISO 3166|name|826|isoname=yes}} → United Kingdom of Great Britain and Northern Ireland

Alpha-2

To get the alpha 2 code use the code function

  • {{#invoke:ISO 3166|code|826}} → GB
  • {{#invoke:ISO 3166|code|United Kingdom}} → GB
  • {{#invoke:ISO 3166|code|UK}} → GB

Alpha-3

To get the alpha 3 code use the code function with codetype = 3

  • {{#invoke:ISO 3166|code|United Kingdom|codetype=alpha3}} → GBR
  • {{#invoke:ISO 3166|name|GB|codetype=alpha3}}
  • {{#invoke:ISO 3166|name|GBR|codetype=alpha3}}
  • {{#invoke:ISO 3166|name|826|codetype=alpha3}}
  • {{#invoke:ISO 3166|code|UK|codetype=alpha3}} → GBR

Numeric

To get the numeric code use the code function with codetype = numeric or use the numeric function

  • {{#invoke:ISO 3166|numeric|GB}} → 826
  • {{#invoke:ISO 3166|code|GB|codetype=numeric}} → 826

Subdivisions (ISO 3166-2)

Inputs to name must be valid ISO 3166-2 codes, i.e. the country's alpha-2 code for the first part, and up to three alphanumeric characters for the second part. They may be given normally (with a hyphen between the parts), or split between two unnamed parameters. For code, the first parameter is the country name (or any of its three codes, like above), and the second the subdivision name.

Code (alpha-2)

To get the alpha-2 code of a subdivision use the code function with parameter 1 being the country and parameter 2 being the subdivision

  • {{#invoke:ISO 3166|code|United Kingdom|England}} → GB-ENG
  • {{#invoke:ISO 3166|code|GBR|England}} → GB-ENG
  • {{#invoke:ISO 3166|code|GB|England}} → GB-ENG

Name

To get the name of a subdivision use the name function with parameter 1 being the country and parameter 2 being the subdivsion or parameter 1 being the subdivsion code

  • {{#invoke:ISO 3166|name|GB-ENG}} → England
  • {{#invoke:ISO 3166|name|GB|ENG}} → England

|isoname= works for subnational entities as well; keep in mind that ISO 3166-2 uses (transliterations of) local names that may differ from English ones. Set |lang= to a language code to switch between different languages for entities that have multiple ISO names. The default language for multilingual entities can be set on the country's data page.

  • {{#invoke:ISO 3166|name|BE|BRU}} → Brussels
  • {{#invoke:ISO 3166|name|BE|BRU|isoname=yes}} → Bruxelles-Capitale, Région de
  • {{#invoke:ISO 3166|name|BE|BRU|lang=fr}} → Bruxelles-Capitale, Région de
  • {{#invoke:ISO 3166|name|BE|BRU|lang=nl}} → Brussels Hoofdstedelijk Gewest

Tracking categories

See also

Subpages