Jump to content

Template:ISO 3166 conversion template doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
copy-edit
 
(44 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Lua|Module:ISO 3166}}
<noinclude>
{{Documentation}}
</noinclude>{{{{{|safesubst:}}}#invoke:Unsubst||subst=|$flags=override,keep-whitespace,remove-empty|$B={{Documentation|1=Template:ISO 3166 conversion template doc|content=
==Usage==
{{#switch:{{NAMESPACE}}
|Template=This template is part of a series that resolves the country and subdivision names to [[ISO 3166-1]] and [[ISO 3166-2]] codes, and vice versa.
|Category=This category contains part of the series of templates resolves the country and subdivision names to [[ISO 3166-1]] and [[ISO 3166-2]] codes, and vice versa.
|This {{lcfirst:{{NAMESPACE}}}} relates to a series of templates resolves the country and subdivision names to [[ISO 3166-1]] and [[ISO 3166-2]] codes, and vice versa.
}}{{#ifeq:{{Str len|{{{3|}}}}}|2|See also: [[ISO 3166-2:{{{3}}}]]}}{{#if:{{{spec|}}}|
==Special case==
{{{spec|}}}
}}
==Sub-pages==
{{Special:Prefixindex/{{SUBJECTPAGENAME}}}}


This template is part of a series that resolves the country and subdivision names to [[ISO 3166-1]] and [[ISO 3166-2]] codes, and vice versa. {{#ifeq:{{Str len|{{{3|}}}}}|2|See also: [[ISO 3166-2:{{{3}}}]]}} ISO 3166 defines names, two and three letter codes and code numbers for all countries and six character codes (the two letter country code followed by a dash and a two or three character subdivision code) for all top level subdivisions.
==ISO 3166==
ISO 3166 defines names, two and three letter codes and code numbers for all countries and six character codes (the two letter country code followed by a dash and a two or three character subdivision code) for all top level subdivisions.


==Templates==
==Templates==
===ISO 3166-1===
===ISO 3166-1===
ISO 3166-1 alpha-2: {{Tl|ISO 3166 code}} (Eg: {{ISO 3166 code|Canada}})
* ISO 3166-1 alpha-2: {{Tl|ISO 3166 code}} (''e.g.'', {{ISO 3166 code|Iran}})
* ISO 3166-1 alpha-3: {{Tl|ISO 3166 code-3}} (''e.g.'', {{ISO 3166 code-3|Iran}})
* ISO 3166-1 numeric: {{Tl|ISO 3166 numeric}} (''e.g.'', {{ISO 3166 numeric|Iran}})


ISO 3166-1 alpha-3: {{Tl|ISO 3166 code-3}} (Eg: {{ISO 3166 code-3|Canada}})

ISO 3166-1 numeric: {{Tl|ISO 3166 numeric}} (Eg: {{ISO 3166 numeric|Canada}})
===ISO 3166-2===
===ISO 3166-2===
ISO 3166-2: {{Tl|ISO 3166 code}} (Eg: {{ISO 3166 code|Canada|Ontario}})
* ISO 3166-2: {{Tl|ISO 3166 code}} (''e.g.'', {{ISO 3166 code|Iran|Alborz}})
* ISO 3166-2 name: {{Tl|ISO 3166 name}} (''e.g.'', {{ISO 3166 name|Iran}})


===Non-ISO 3166===
''ISO 3166-2'' name: {{tl|ISO 3166 name}} (Eg: {{ISO 3166 name|CAN}})
Country name: {{Tl|Country name}} (''e.g.'', {{Country name|Iran}})


==Usage==
<!--===ISO 3166-3===
When we wish to convert between various identifiers that may loosely be defined as ''user input'' and ISO 3166 entities, there may be more than one way to do each conversion. For our examples we use [[Pakistan]] as the country and [[Balochistan (Pakistan)]] as the subdivision.
ISO 3166-3:-->
==Using the family of templates==
We wish to convert between various identifiers that may loosely be defined as ''user input'' and ISO 3166 entities, there may be more than one way to do each conversion. For our examples we use [[Pakistan]] as the country and [[Balochistan (Pakistan)]] as the subdivision.


The ISO-3166 identifiers for Pakistan are:
The ISO-3166 identifiers for Pakistan are:
*Name: Pakistan
* Name: Pakistan
*Alpha-2 code:PK
* Alpha-2 code: PK
*Alpha-3 code:PAK
* Alpha-3 code: PAK
*Numeric code:586
* Numeric code: 586


The ISO-3166 identifiers for Balochistan (Pakistan) is:
The ISO-3166 identifiers for Balochistan (Pakistan) is:
*Subdivision code:PK-BK
* Subdivision code:PK-BK


Now Pakistan also has a number of synonyms: for example [[Pakistán]] and [[پاکستان]].
Now Pakistan also has a number of synonyms, for example, [[Pakistán]] and [[پاکستان]].


Similarly Baluchistan is known, for example as [[Balochistan]] (on Wikipedia) and [[Bagh Sanjari]] .
Similarly Baluchistan is known, for example, as [[Balochistan]] (on Wikipedia) and [[Bagh Sanjari]].


=== Finding the Alpha-2 code ===
; To get the '''Alpha-2''' code we can use {{Tlx|ISO 3166 code}} with any of the country identifiers ,or use the identifier as a part of the template name (faster).
Any of the country identifiers can be used.


* {{Tlx|ISO 3166 code|Pakistan}} PK
* {{Tlx|ISO 3166 code|Pakistan}} PK
* {{Tlx|ISO 3166 code|PK}} PK
* {{Tlx|ISO 3166 code|PK}} PK
* {{Tlx|ISO 3166 code|PAK}} PK
* {{Tlx|ISO 3166 code|PAK}} PK
* {{Tlx|ISO 3166 code|586}} PK
* {{Tlx|ISO 3166 code|586}} PK
* {{Tlx|ISO 3166 code|Pakistán}} PK
* {{Tlx|ISO 3166 code|Pakistán}} PK
* {{Tlx|ISO 3166 code|پاکستان}} PK
* {{Tlx|ISO 3166 code|پاکستان}} PK


=== Finding the Alpha-3 code ===
; The '''Alpha-3''' code is obtained similarly (but not currently using the template name method except for conversion from known good '''Alpha-2''').


* {{Tlx|ISO 3166 code-3|Pakistan}} PAK
* {{Tlx|ISO 3166 code-3|Pakistan}} PAK
* {{Tlx|ISO 3166 code-3|PK}} PAK
* {{Tlx|ISO 3166 code-3|PK}} PAK
* {{Tlx|ISO 3166 code-3|PAK}} PAK
* {{Tlx|ISO 3166 code-3|PAK}} PAK
* {{Tlx|ISO 3166 code-3|586}} PAK
* {{Tlx|ISO 3166 code-3|586}} PAK
* {{Tlx|ISO 3166 code-3|Pakistán}} PAK
* {{Tlx|ISO 3166 code-3|Pakistán}} PAK
* {{Tlx|ISO 3166 code-3|پاکستان}} PAK
* {{Tlx|ISO 3166 code-3|پاکستان}} PAK


=== Finding the name of a country ===
;Finding the name is obtained similarly (but not currently using the template name method except for conversion from known good '''Alpha-2''').


* {{Tlx|ISO 3166 name|Pakistan}} Pakistan
* {{Tlx|ISO 3166 name|Pakistan}} Pakistan
* {{Tlx|ISO 3166 name|PK}} Pakistan
* {{Tlx|ISO 3166 name|PK}} Pakistan
* {{Tlx|ISO 3166 name|PAK}} Pakistan
* {{Tlx|ISO 3166 name|PAK}} Pakistan
* {{Tlx|ISO 3166 name|586}} Pakistan
* {{Tlx|ISO 3166 name|586}} Pakistan
* {{Tlx|ISO 3166 name|Pakistán}} Pakistan
* {{Tlx|ISO 3166 name|Pakistán}} Pakistan
* {{Tlx|ISO 3166 name|پاکستان}} Pakistan
* {{Tlx|ISO 3166 name|پاکستان}} Pakistan


;Finding the numeric code of a country.
=== Finding the common name of a country ===


* {{Tlx|ISO 3166 numeric|Pakistan}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|Pakistan}} Pakistan
* {{Tlx|ISO 3166 numeric|PK}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|PK}} Pakistan
* {{Tlx|ISO 3166 numeric|PAK}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|PAK}} Pakistan
* {{Tlx|ISO 3166 numeric|586}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|586}} Pakistan
* {{Tlx|ISO 3166 numeric|Pakistán}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|Pakistán}} Pakistan
* {{Tlx|ISO 3166 numeric|پاکستان}} {{#invoke:ISO 3166|code|Pakistan|codetype=numeric}}
* {{Tlx|Country name|پاکستان}} Pakista


=== Finding the numeric code of a country ===
;The subdivision code can be obtained in the following ways


* {{Tlx|ISO 3166 code|Pakistan|Baluchistan}} PK-BA
* {{Tlx|ISO 3166 numeric|Pakistan}} 586
* {{Tlx|ISO 3166 code|Pakistan|Balochistan}} PK-BA
* {{Tlx|ISO 3166 numeric|PK}} 586
* {{Tlx|ISO 3166 code|Pakistan|Bagh Sanjari}} PK-BA
* {{Tlx|ISO 3166 numeric|PAK}} 586
* {{Tlx|ISO 3166 code|Pakistán|Baluchistan}} PK-BA
* {{Tlx|ISO 3166 numeric|586}} 586
* {{Tlx|ISO 3166 code|Paquistán|Balochistan}} PK-BA
* {{Tlx|ISO 3166 numeric|Pakistán}} 586
* {{Tlx|ISO 3166 code|PK|Baluchistan}} PK-BA


==Cases where the non-ISO3166 name might be returned==
=== Finding the subdivision code ===
* Taiwan - ISO name is...
* Venezuela - ISO name is...
* Bolivia - ISO name is....
* ...


* {{Tlx|ISO 3166 code|Pakistan|Baluchistan}} PK-BA
* Cases where the name is comma mangled - "Congo, The People's Democratic Republic of"
* {{Tlx|ISO 3166 code|Pakistan|Balochistan}} PK-BA
* Macedonia - ISO name is Macedonia, the former Yugoslav Republic of
* {{Tlx|ISO 3166 code|Pakistan|Bagh Sanjari}} PK-BA
* {{Tlx|ISO 3166 code|Pakistán|Baluchistan}} PK-BA
* {{Tlx|ISO 3166 code|Paquistán|Balochistan}} PK-BA
* {{Tlx|ISO 3166 code|PK|Baluchistan}} PK-BA


<includeonly>{{Sandbox other||
==Enhancing the system==
[[Category:ISO 3166 templates]]
# Adding country synonyms: these should redirect to the canonical template: the redirect should be categorised the same as the target, and sort-keyed as per the notes in the categories.
[[Category:Data retrieval templates]]
# Adding region synonyms: these can be a simple cut-and paste, but be sure to update any documentation variables.
}}</includeonly><noinclude>

{{Documentation}}
}}

<includeonly>{{#ifeq:{{{4|}}}|name|{{#if:{{{2|}}}|[[Category:ISO 3166 name from code templates{{!}}{{{1}}} {{{2}}}]]|[[Category:ISO 3166 name from code country templates{{!}}{{{1|}}}]]}}|{{#if:{{{2|}}}|[[Category:ISO 3166 code from name templates{{!}}{{{1}}} {{{2}}}]]|[[Category:ISO 3166 code from name country templates{{!}}{{{1|}}}]]}}}}</includeonly>
}}<noinclude>
[[Category:Template documentation]]
</noinclude>
</noinclude>

Latest revision as of 19:02, 28 August 2022

This template is part of a series that resolves the country and subdivision names to ISO 3166-1 and ISO 3166-2 codes, and vice versa. ISO 3166 defines names, two and three letter codes and code numbers for all countries and six character codes (the two letter country code followed by a dash and a two or three character subdivision code) for all top level subdivisions.

Templates

ISO 3166-1

ISO 3166-2

Non-ISO 3166

Country name: {{Country name}} (e.g., Iran)

Usage

When we wish to convert between various identifiers that may loosely be defined as user input and ISO 3166 entities, there may be more than one way to do each conversion. For our examples we use Pakistan as the country and Balochistan (Pakistan) as the subdivision.

The ISO-3166 identifiers for Pakistan are:

  • Name: Pakistan
  • Alpha-2 code: PK
  • Alpha-3 code: PAK
  • Numeric code: 586

The ISO-3166 identifiers for Balochistan (Pakistan) is:

  • Subdivision code:PK-BK

Now Pakistan also has a number of synonyms, for example, Pakistán and پاکستان.

Similarly Baluchistan is known, for example, as Balochistan (on Wikipedia) and Bagh Sanjari.

Finding the Alpha-2 code

Any of the country identifiers can be used.

Finding the Alpha-3 code

Finding the name of a country

Finding the common name of a country

Finding the numeric code of a country

Finding the subdivision code