JavaScript根据国家二字码获取国家全称

这篇博客分享了如何利用JavaScript根据国家二字码来获取对应的国家全称,主要面向前端UI开发中的国际化需求。
摘要由CSDN通过智能技术生成
  1 function getCountryNameByCode(code) {
  2     var countryName = '';
  3     switch(code) {
  4     case "US":
  5         countryName = "United State";
  6         break;
  7     case "GB":
  8         countryName = "United Kingdom";
  9         break;
 10     case "DE":
 11         countryName = "Germany";
 12         break;
 13     case "CA":
 14         countryName = "Canada";
 15         break;
 16     case "JP":
 17         countryName = "Japan";
 18         break;
 19     case "ES":
 20         countryName = "Spain";
 21         break;
 22     case "FR":
 23         countryName = "France";
 24         break;
 25     case "IT":
 26         countryName = "Italy";
 27         break;
 28     case "CN":
 29         countryName = "China";
 30         break;
 31     case "AT":
 32         countryName = "Austria";
 33         break;
 34     case "AU":
 35         countryName = "Australian";
 36         break;
 37     case "CH":
 38         countryName = "Switzerland";
 39         break;
 40     case "EG":
 41         countryName = "Egypt";
 42         break;
 43     case "FI":
 44         countryName = "Finland";
 45         break;
 46     case "IN":
 47         countryName = "India";
 48         break;
 49     case "IE":
 50         countryName = "Ireland";
 51         break;
 52     case "ID":
 53         countryName = "Indonesia";
 54         break;
 55     case "KH":
 56         countryName = "Cambodia";
 57         break;
 58     case "KR":
 59         countryName = "Korea";
 60         break;
 61     case "MX":
 62         countryName = "Mexico";
 63         break;
 64     case "NL":
 65         countryName = "Holland";
 66         break;
 67     case "NO":
 68         countryName = "Norway";
 69         break;
 70     case "MM":
 71         countryName = "Burma";
 72         break;
 73     case "PH":
 74         countryName = "Philippines";
 75         break;
 76     case "BE":
 77         countryName = "Belgium";
 78         break;
 79     case "GY":
 80         countryName = "Guyana";
 81         break;
 82     case "SE":
 83         countryName = "Sweden";
 84         break;
 85     case "PY":
 86         countryName = "Paraguay";
 87         break;
 88     case "UA":
 89         countryName = "Ukraine";
 90         break;
 91     case "PE":
 92         countryName = "Peru";
 93         break;
 94     case "AE":
 95         countryName = "United Arab Emirates";
 96         break;
 97     case "VN":
 98         countryName = "Vietnam";
 99         break;
100     case "SO":
101         countryName = "Somalia";
102         break;
103     case "LA":
104         countryName = "Laos";
105         break;
106     case "KW":
107         countryName = "Kuwait";
108         break;
109     case "MY":
110         countryName = "Malaysia";
111         break;
112     case "DK":
113         countryName = "Denmark";
114         break;
115     case "PK":
116         countryName = "Pakistan";
117         break;
118     case "TH":
119         countryName = "Thailand";
120         break;
121     case "HU":
122         countryName = "HUNGARY";
123         break;
124     case "LV":
125         countryName = "Latvia";
126         break;
127     case "RU":
128         countryName = "Russia";
129         break;
130     case "CZ":
131         countryName = "Czech Republic";
132         break;
133     case "PL":
134         countryName = "Poland";
135         break;
136     case "BY":
137         countryName = "Belarus";
138         break;
139     case "LT":
140         countryName = "Lithuania";
141         break;
142     case "LU":
143         countryName = "Luxembourg";
144         break;
145     cas
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值