Difference between revisions of "Template:ConvertAbbrev/ISO 3166-1/numeric"

From blackwiki
Jump to navigation Jump to search
imported>Dudemanfellabra
(add support for "force" parameter)
imported>Dudemanfellabra
(implement case insensitivity)
Line 250: Line 250:
 
| {{#ifeq:{{{force|}}}|long|{{{1}}}}}
 
| {{#ifeq:{{{force|}}}|long|{{{1}}}}}
 
}}}}{{#ifeq:{{{force|}}}|long||
 
}}}}{{#ifeq:{{{force|}}}|long||
{{#switch: {{{1}}}
+
{{#switch: {{lc:{{{1}}}}}
|Andorra=020
+
|andorra=020
|United Arab Emirates|UAE|U.A.E.=784
+
|united arab emirates|uae|u.a.e.=784
|Afghanistan=004
+
|afghanistan=004
|Antigua and Barbuda=028
+
|antigua and barbuda=028
|Anguilla=660
+
|anguilla=660
|Albania=008
+
|albania=008
|Armenia=051
+
|armenia=051
|Netherlands Antilles=530
+
|netherlands antilles=530
|Angola=024
+
|angola=024
|Antarctica|Antarctique=010
+
|antarctica|antarctique=010
|Argentina=032
+
|argentina=032
|American Samoa=016
+
|american samoa=016
|Austria=040
+
|austria=040
|Australia=036
+
|australia=036
|Aruba=533
+
|aruba=533
|Aland Islands=248
+
|aland islands=248
|Azerbaijan=031
+
|azerbaijan=031
|Bosnia and Herzegovina|Bosnia|Herzegovina=070
+
|bosnia and herzegovina|bosnia|herzegovina=070
|Barbados=052
+
|barbados=052
|Bangladesh=050
+
|bangladesh=050
|Belgium=056
+
|belgium=056
|Burkina Faso|Upper Volta=854
+
|burkina faso|upper volta=854
|Bulgaria=100
+
|bulgaria=100
|Bahrain=048
+
|bahrain=048
|Burundi=108
+
|burundi=108
|Benin|Dahomey=204
+
|benin|dahomey=204
|Saint Barthelemy|St. Barthelemy=652
+
|saint barthelemy|st. barthelemy|st barthelemy=652
|Bermuda=060
+
|bermuda=060
|Brunei Darussalam|Brunei=096
+
|brunei darussalam|brunei=096
|Bolivia=068
+
|bolivia=068
|Brazil=076
+
|brazil=076
|Bahamas=044
+
|bahamas=044
|Bhutan=064
+
|bhutan=064
|Bouvet Island=074
+
|bouvet island=074
|Botswana=072
+
|botswana=072
|Belarus=112
+
|belarus=112
|Belize=084
+
|belize=084
|Canada=124
+
|canada=124
|Cocos Islands|Cocos (Keeling) Islands|Keeling Islands=166
+
|cocos islands|cocos (keeling) islands|keeling islands=166
|Congo, the Democratic Republic of the|The Democratic Republic of the Congo|Zaire=180
+
|congo, the democratic republic of the|the democratic republic of the congo|zaire=180
|Central African Republic=140
+
|central african republic=140
|Congo=178
+
|congo=178
|Switzerland|Confoederatio Helvetica=756
+
|switzerland|confoederatio helvetica=756
|Cote d'Ivoire|Ivory Coast=384
+
|cote d'ivoire|ivory coast=384
|Cook Islands=184
+
|cook islands=184
|Chile=152
+
|chile=152
|Cameroon=120
+
|cameroon=120
|China=156
+
|china=156
|Colombia=170
+
|colombia=170
|Costa Rica=188
+
|costa rica=188
|Cuba=192
+
|cuba=192
|Cape Verde=132
+
|cape verde=132
|Christmas Island=162
+
|christmas island=162
|Cyprus=196
+
|cyprus=196
|Czech Republic=203
+
|czech republic=203
|Deutschland|Federal Republic of Germany|Germany|Germany, Federal Republic of=276
+
|deutschland|federal republic of germany|germany|germany, federal republic of=276
|Djibouti|French Afar and Issas=262
+
|djibouti|french afar and issas=262
|Denmark=208
+
|denmark=208
|Dominica=212
+
|dominica=212
|Dominican Republic=214
+
|dominican republic=214
|Algeria|Ledzayer=012
+
|algeria|ledzayer=012
|Ecuador=218
+
|ecuador=218
|Estonia|Eesti=233
+
|estonia|eesti=233
|Egypt=818
+
|egypt=818
|Sahara espanol|Spanish Sahara|Western Sahara=732
+
|sahara espanol|spanish sahara|western sahara=732
|Eritrea=232
+
|eritrea=232
|Espana|Spain|Canary Islands|Ceuta|Melilla=724
+
|espana|spain|canary islands|ceuta|melilla=724
|Ethiopia=231
+
|ethiopia=231
|Finland=246
+
|finland=246
|Fiji=242
+
|fiji=242
|Falkland Islands|Falkland Islands (Malvinas)|Malvinas=238
+
|falkland islands|falkland islands (malvinas)|malvinas=238
|Federated States of Micronesia|Micronesia|Micronesia, Federated States of=583
+
|federated states of micronesia|micronesia|micronesia, federated states of=583
|Faroe Islands=234
+
|faroe islands=234
|France|Clipperton Island=250
+
|france|clipperton island=250
|Gabon=266
+
|gabon=266
|Great Britain|Northern Ireland|United Kingdom|United Kingdom of Great Britain and Northern Ireland=826
+
|great britain|northern ireland|united kingdom|united kingdom of great britain and northern ireland=826
|Grenada=308
+
|grenada=308
|Georgia=268
+
|georgia=268
 
<!--
 
<!--
|Gilbert and Ellice Islands=
+
|gilbert and ellice islands=
 
-->
 
-->
|French Guiana|Guyane francaise=254
+
|french guiana|guyane francaise=254
|Guernsey=831
+
|guernsey=831
|Ghana=288
+
|ghana=288
|Gibraltar=292
+
|gibraltar=292
|Greenland=304
+
|greenland=304
|Gambia=270
+
|gambia=270
|Guinea=324
+
|guinea=324
|Guadeloupe=312
+
|guadeloupe=312
|Equatorial Guinea|Guinee equatoriale=226
+
|equatorial guinea|guinee equatoriale=226
|Greece=300
+
|greece=300
|South Georgia|South Georgia and the South Sandwich Islands|South Sandwich Islands=239
+
|south georgia|south georgia and the south sandwich islands|south sandwich islands=239
|Guatemala=320
+
|guatemala=320
|Guam=316
+
|guam=316
|Guinea-Bissau=624
+
|guinea-bissau=624
|Guyana=328
+
|guyana=328
|Hong Kong=344
+
|hong kong=344
|Heard Island|Heard Island and McDonald Islands|McDonald Islands=334
+
|heard island|heard island and mcdonald islands|mcdonald islands=334
|Honduras=340
+
|honduras=340
|Croatia|Hrvatska=191
+
|croatia|hrvatska=191
|Haiti=332
+
|haiti=332
|Hungary=348
+
|hungary=348
|Indonesia=360
+
|indonesia=360
|Ireland=372
+
|ireland=372
|Israel=376
+
|israel=376
|Isle of Man=833
+
|isle of man=833
|India=356
+
|india=356
|British Indian Ocean Territory|Diego Garcia=086
+
|british indian ocean territory|diego garcia=086
|Iraq=368
+
|iraq=368
|Iran, Islamic Republic of|Islamic Republic of Iran|Iran=364
+
|iran, islamic republic of|islamic republic of iran|iran=364
|Iceland=352
+
|iceland=352
|Italy=380
+
|italy=380
|Jersey=832
+
|jersey=832
|Jamaica=388
+
|jamaica=388
|Jordan=400
+
|jordan=400
|Japan=392
+
|japan=392
|Kenya=404
+
|kenya=404
|Kyrgyzstan=417
+
|kyrgyzstan=417
|Cambodia|Kampuchea=116
+
|cambodia|kampuchea=116
|Kiribati=296
+
|kiribati=296
|Comoros|Komori=174
+
|comoros|komori=174
|Saint Kitts and Nevis|Saint Kitts-Nevis-Anguilla|St Kitts and Nevis|St. Kitts and Nevis=659
+
|saint kitts and nevis|saint kitts-nevis-anguilla|st kitts and nevis|st. kitts and nevis=659
|Democratic People's Republic of Korea|Korea, Democratic People's Republic of|North Korea|DPRK=408
+
|democratic people's republic of korea|korea, democratic people's republic of|north korea|dprk=408
|Korea, Republic of|Republic of Korea|South Korea=410
+
|korea, republic of|republic of korea|south korea=410
|Kuwait=414
+
|kuwait=414
|Cayman Islands=136
+
|cayman islands=136
|Kazakhstan|Kazakstan=398
+
|kazakhstan|kazakstan=398
|Lao People's Democratic Republic|Laos=418
+
|lao people's democratic republic|laos=418
|Lebanon=422
+
|lebanon=422
|Saint Lucia=662
+
|saint lucia=662
|Liechtenstein=438
+
|liechtenstein=438
|Sri Lanka=144
+
|sri lanka=144
|Liberia=430
+
|liberia=430
|Lesotho=426
+
|lesotho=426
|Lithuania=440
+
|lithuania=440
|Luxembourg=442
+
|luxembourg=442
|Latvia=428
+
|latvia=428
|Libyan Arab Jamahiriya|Lybia=434
+
|libyan arab jamahiriya|lybia=434
|Maroc|Morocco=504
+
|maroc|morocco=504
|Monaco=492
+
|monaco=492
|Moldova|Moldova, Republic of|Republic of Moldova=498
+
|moldova|moldova, republic of|republic of moldova=498
|Montenegro=499
+
|montenegro=499
|Saint Martin|Saint Martin (French part)=663
+
|saint martin|saint martin (french part)=663
|Madagascar=450
+
|madagascar=450
|Marshall Islands=584
+
|marshall islands=584
|Macedonia, the former Yugoslav Republic of|Makedonija|The former Yugoslav Republic of Macedonia|Macedonia=807
+
|macedonia, the former yugoslav republic of|makedonija|the former yugoslav republic of macedonia|macedonia=807
|Mali=466
+
|mali=466
|Burma|Myanmar=104
+
|burma|myanmar=104
|Mongolia=496
+
|mongolia=496
|Macao|Macau=446
+
|macao|macau=446
|Northern Mariana Islands=580
+
|northern mariana islands=580
|Martinique=474
+
|martinique=474
|Mauritania=478
+
|mauritania=478
|Montserrat=500
+
|montserrat=500
|Malta=470
+
|malta=470
|Mauritius=480
+
|mauritius=480
|Maldives=462
+
|maldives=462
|Malawi=454
+
|malawi=454
|Mexico=484
+
|mexico=484
|Malaysia=458
+
|malaysia=458
|Mozambique=508
+
|mozambique=508
|Namibia=516
+
|namibia=516
|New Caledonia=540
+
|new caledonia=540
|Niger=562
+
|niger=562
|Norfolk Island=574
+
|norfolk island=574
|Nigeria=566
+
|nigeria=566
|Nicaragua=558
+
|nicaragua=558
|Netherlands=528
+
|netherlands=528
|Norway=578
+
|norway=578
|Nepal=524
+
|nepal=524
|Nauru=520
+
|nauru=520
|Niue=570
+
|niue=570
|New Zealand=554
+
|new zealand=554
|Oman=512
+
|oman=512
|Panama=591
+
|panama=591
|Peru=604
+
|peru=604
|French Polynesia|Polynesie francaise=258
+
|french polynesia|polynesie francaise=258
|Papua New Guinea=598
+
|papua new guinea=598
|Philippines=608
+
|philippines=608
|Pakistan=586
+
|pakistan=586
|Poland=616
+
|poland=616
|Miquelon|Saint Pierre|Saint Pierre and Miquelon=666
+
|miquelon|saint pierre|saint pierre and miquelon|st. pierre|st pierre|st. pierre and miquelon|st pierre and miquelon=666
|Pitcairn=612
+
|pitcairn=612
|Puerto Rico=630
+
|puerto rico=630
|Gaza Strip|Occupied Palestinian Territory|Palestinian Territory|Palestinian Territory, Occupied|West Bank|Palestine=275
+
|gaza strip|occupied palestinian territory|palestinian territory|palestinian territory, occupied|west bank|palestine=275
|Portugal=620
+
|portugal=620
|Palau=585
+
|palau=585
|Paraguay=600
+
|paraguay=600
|Qatar=634
+
|qatar=634
|Reunion=638
+
|reunion=638
|Romania=642
+
|romania=642
|Serbia|Republic of Serbia=688
+
|serbia|republic of serbia=688
|Russian Federation|Russia=643
+
|russian federation|tussia=643
|Rwanda=646
+
|rwanda=646
|Saudi Arabia=682
+
|saudi arabia=682
|British Solomon Islands|Solomon Islands=090
+
|british solomon islands|solomon islands=090
|Seychelles=690
+
|seychelles=690
|Sudan=736
+
|sudan=736
|Sweden=752
+
|sweden=752
|Singapore=702
+
|singapore=702
|Ascension Island|Saint Helena|Tristan da Cunha=654
+
|ascension island|saint helena|st. helena|st helena|tristan da cunha=654
|Slovenia=705
+
|slovenia=705
|Jan Mayen|Svalbard|Svalbard and Jan Mayen=744
+
|jan mayen|svalbard|svalbard and jan mayen=744
|Slovakia=703
+
|slovakia=703
 
<!--
 
<!--
Sikkim=
+
sikkim=
 
-->
 
-->
|Sierra Leone=694
+
|sierra leone=694
|San Marino=674
+
|san marino=674
|Senegal=686
+
|senegal=686
|Somalia=706
+
|somalia=706
|Suriname=740
+
|suriname=740
|Sao Tome and Principe=678
+
|sao tome and principe=678
|El Salvador=222
+
|el salvador=222
|Syrian Arab Republic|Syria=760
+
|syrian arab republic|syria=760
|Swaziland=748
+
|swaziland=748
|Turks and Caicos Islands=796
+
|turks and caicos islands=796
|Chad|Tchad=148
+
|chad|tchad=148
|French Antarctic Lands|French Southern Lands|French Southern Territories|Terres australes francaises=260
+
|french antarctic lands|french southern lands|french southern territories|terres australes francaises=260
|Togo=768
+
|togo=768
|Thailand=764
+
|thailand=764
|Tajikistan=762
+
|tajikistan=762
|Tokelau=772
+
|tokelau=772
|Timor-Leste|East Timor=626
+
|timor-leste|east timor=626
|Turkmenistan=795
+
|turkmenistan=795
|Tunisia=788
+
|tunisia=788
|Tonga=776
+
|tonga=776
|Turkey=792
+
|turkey=792
|Trinidad and Tobago=780
+
|trinidad and tobago=780
|Tuvalu=798
+
|tuvalu=798
|Province of China, Taiwan|Republic of China|Taiwan|Taiwan, Province of China=158
+
|province of china, taiwan|republic of china|taiwan|taiwan, province of china=158
|Tanzania, United Republic of|United Republic of Tanzania|Tanzania=834
+
|tanzania, united republic of|united republic of tanzania|tanzania=834
|Ukraine|Ukrainian S.S.R.=804
+
|ukraine|ukrainian s.s.r.=804
|Uganda=800
+
|uganda=800
|United States Minor Outlying Islands|Baker Island|Howland Island|Jarvis Island|Johnston Atoll|Kingman Reef|Midway Atoll|Navassa Island|Palmyra Atoll|Wake Island=581
+
|united states minor outlying islands|baker island|howland island|jarvis island|johnston atoll|kingman reef|midway atoll|navassa island|palmyra atoll|wake island=581
|United States|United States of America=840
+
|united States|united states of america=840
|Uruguay=858
+
|uruguay=858
|Uzbekistan=860
+
|uzbekistan=860
|Holy See|Holy See (Vatican City State)|Vatican City State|Vatican City State (Holy See)|Vatican City=336
+
|holy see|holy see (vatican city state)|vatican city state|vatican city state (holy see)|vatican city=336
|Saint Vincent and the Grenadines=670
+
|saint vincent and the grenadines=670
|Venezuela=862
+
|venezuela=862
|British Virgin Islands|Virgin Islands, British=092
+
|british virgin islands|virgin islands, british=092
|U.S. Virgin Islands|Virgin Islands, U.S.=850
+
|u.s. virgin islands|virgin islands, u.s.=850
|Viet Nam|Vietnam=704
+
|viet nam|vietnam=704
|New Hebrides|Vanuatu=548
+
|new hebrides|vanuatu=548
|Wallis and Futuna=876
+
|wallis and futuna=876
|Samoa|Western Samoa=882
+
|samoa|western samoa=882
|Yemen|Republic of Yemen|Yemen, Republic of=887
+
|yemen|republic of yemen|yemen, republic of=887
|Mayotte=175
+
|mayotte=175
|South Africa|Zuid-Afrika=710
+
|south africa|zuid-afrika=710
|Zambia=894
+
|zambia=894
|Zimbabwe=716
+
|zimbabwe=716
 
| {{#ifeq:{{{force|}}}|abbr|{{uc:{{{1}}}}}}}
 
| {{#ifeq:{{{force|}}}|abbr|{{uc:{{{1}}}}}}}
 
}}}}<noinclude>{{Documentation|Template:ConvertAbbrev/doc}}</noinclude>
 
}}}}<noinclude>{{Documentation|Template:ConvertAbbrev/doc}}</noinclude>

Revision as of 17:21, 21 August 2011

Template documentation[view] [edit] [history] [purge]

This template is used to convert commonly abbreviated things such as countries, states, provinces, and even language codes to and from their abbreviations. A hierarchical tree of subtemplates allows this template to convert virtually anything, which is really good for use in a backdoor template. If you have the word "California", but the template you're trying to use will only recognize "CA", use this to convert it!

How to use the template

Syntax: {{ConvertAbbrev|datatype|specification|value|force=abbr or long}}

This template consists of a "tree" of subtemplates containing databases of abbreviations. Each successive parameter in the code input tells the template which database to query. The datatype parameter is the most broad and tells the template what type of information you are looking for (i.e. Countries, states, or languages). The specification parameter refines the search. For example, if the datatype parameter is "ISO 3166-1", that tells the template to look for a subtype (alpha2, alpha3, or numeric). If the datatype parameter is "ISO 3166-2", the template will look for a specific country (Canada, Mexico, United States, etc.). If the datatype parameter is "ISO 639-1", the template looks for the name of a language (English, Spanish, Zulu, etc.). The value parameter is the actual name or abbreviation the user wishes to convert.

The force parameter overrides the normal nature of the conversion and forces an abbreviation or a long word to be returned. This is useful when a user may input either an abbreviation or a full name, but the template in question can only accept one of them.

If the ISO codes are a little hard to remember, there are also shortcuts:

  • {{ConvertAbbrev|ISO 3166-1|alpha-2|__country__}} can also be called by
    • {{ConvertAbbrev|Countries|alpha-2|__country__}} or
    • {{ConvertAbbrev|Countries|__country__}}.
      Note: The default for country abbreviations is alpha-2. For alpha-3 and numeric abbreviations, the user must specify the type in the specification parameter.
  • {{ConvertAbbrev|ISO 3166-2|CA|__province__}} can also be called by
  • {{ConvertAbbrev|ISO 639-1|__language__}} can also be called by
    • {{ConvertAbbrev|Languages|-1|__language__}} or
    • {{ConvertAbbrev|Languages|__language__}}.
      Note: The default for language abbreviations is ISO 639-1. For ISO 639-2 abbreviations, the user must specify the type in the specification parameter.
  • {{ConvertAbbrev|ISO 639-2|__language__}} can also be called by

Supported datasets

Countries supported in ISO 3166-2:
  Supported
  Not yet supported
  Does not exist in ISO 3166-2

Usage Examples

From Name to Abbreviation
Code Returns
{{ConvertAbbrev|ISO 3166-1|alpha-2|United Kingdom}} GB
{{ConvertAbbrev|Countries|alpha-3|United States}} USA
{{ConvertAbbrev|ISO 3166-2|CA|Alberta}} AB
{{ConvertAbbrev|Countries|Mexico|Federal District}} DF
{{ConvertAbbrev|ISO 639-1|Russian}} ru
{{ConvertAbbrev|Languages|Chinese}} zh
From Abbreviation to Name
Code Returns
{{ConvertAbbrev|ISO 3166-1|alpha-2|GB}} United Kingdom
{{ConvertAbbrev|Countries|alpha-3|USA}} United States
{{ConvertAbbrev|ISO 3166-2|CA|AB}} Alberta
{{ConvertAbbrev|Countries|Mexico|DF}} Federal District
{{ConvertAbbrev|ISO 639-1|ru}} Russian
{{ConvertAbbrev|Languages|zh}} Chinese

Sub-pages

For a list of all the sub-pages of this template, see: Special:PrefixIndex/Template:ConvertAbbrev