Module:ISO 3166/doc: Difference between revisions

Content deleted Content added
Pre-alpha to beta; expand documentation
Line 1:
{{Module rating|pre-alphabeta}}
 
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>).
 
==Examples==
===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.
*{{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|826}} &rarr; {{#invoke:ISO 3166|name|826}}
*{{tnull|&#35;invoke:ISO 3166|code|United Kingdom}} &rarr; {{#invoke:ISO 3166|code|United Kingdom}}
*{{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|826}} &rarr; {{#invoke:ISO 3166|code|826}}
*{{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)===
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.
*{{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}}
*{{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|GB|England}} &rarr; {{#invoke:ISO 3166|code|GB|England}}
 
{{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]].
*{{tnull|&#35;invoke:ISO 3166|name|BE|BRU}} &rarr; {{#invoke:ISO 3166|name|BE|BRU}}
*{{tnull|&#35;invoke:ISO 3166|name|BE|BRU|isoname{{=}}yes}} &rarr; {{#invoke:ISO 3166|name|BE|BRU|isoname=yes}}
*{{tnull|&#35;invoke:ISO 3166|name|BE|BRU|lang{{=}}fr}} &rarr; {{#invoke:ISO 3166|name|BE|BRU|lang=fr}}
*{{tnull|&#35;invoke:ISO 3166|name|BE|BRU|lang{{=}}nl}} &rarr; {{#invoke:ISO 3166|name|BE|BRU|lang=nl}}
 
==See also==