我有这个货币清单(来自https://openexchangerates.org)
{"AED":3.6729,"AFN":57.82755,"ALL":103.465001,"AMD":414.905,"ANG":1.787,"AOA":97.659999,"ARS":8.131418,"AUD":1.065732,"AWG":1.79,"AZN":0.7839,"BAM":1.445344,"BBD":2,"BDT":77.618221,"BGN":1.44457,"BHD":0.376997,"BIF":1553.3484,"BMD":1,"BND":1.25077,"BOB":6.90997,"BRL":2.2253,"BSD":1,"BTC":0.0016610606,"BTN":60.00055,"BWP":8.865137,"BYR":10173.333333,"BZD":1.99474,"CAD":1.087393,"CDF":926.513333,"CHF":0.899613,"CLF":0.0232,"CLP":556.539996,"CNY":6.210708,"COP":1880.283333,"CRC":556.712998,"CUP":0.9999,"CVE":81.0433,"CZK":20.26093,"DJF":178.380299,"DKK":5.507907,"DOP":43.27396,"DZD":79.3989,"EEK":11.68855,"EGP":7.150895,"ERN":14.952575,"ETB":19.57954,"EUR":0.738639,"FJD":1.825871,"FKP":0.589387,"GBP":0.589387,"GEL":1.76713,"GHS":3.09659,"GIP":0.589387,"GMD":39.6,"GNF":6961.666667,"GTQ":7.81589,"GYD":204.983752,"HKD":7.751421,"HNL":20.82528,"HRK":5.59851,"HTG":45.02112,"HUF":227.0625,"IDR":11812.583333,"ILS":3.458559,"INR":60.06054,"IQD":1177.766717,"IRR":25566,"ISK":114.098,"JEP":0.589387,"JMD":111.226,"JOD":0.70829,"JPY":101.8811,"KES":87.971741,"KGS":51.94185,"KHR":4041.333333,"KMF":363.47686,"KPW":900,"KRW":1019.49,"KWD":0.282206,"KYD":0.826662,"KZT":183.533001,"LAK":8052.216667,"LBP":1511.808333,"LKR":130.250001,"LRD":89.001533,"LSL":10.70319,"LTL":2.5504,"LVL":0.518188,"LYD":1.2312,"MAD":8.27075,"MDL":13.90944,"MGA":2410.6,"MKD":45.37356,"MMK":970.664,"MNT":1823.17334,"MOP":7.98312,"MRO":290.925,"MTL":0.683738,"MUR":30.34428,"MVR":15.45622,"MWK":394.397,"MXN":13.03642,"MYR":3.2241,"MZN":31.50475,"NAD":10.70799,"NGN":163.182999,"NIO":25.87152,"NOK":5.997004,"NPR":96.1525,"NZD":1.152707,"OMR":0.384962,"PAB":1,"PEN":2.7912,"PGK":2.448173,"PHP":43.90592,"PKR":98.54584,"PLN":3.057794,"PYG":4412.258268,"QAR":3.64089,"RON":3.24691,"RSD":85.24262,"RUB":34.58522,"RWF":682.30402,"SAR":3.75081,"SBD":7.2208,"SCR":12.25984,"SDG":5.694417,"SEK":6.645576,"SGD":1.25099,"SHP":0.589387,"SLL":4335,"SOS":936.00202,"SRD":3.308567,"STD":18107.5,"SVC":8.74892,"SYP":149.324999,"SZL":10.73045,"THB":32.35748,"TJS":4.923975,"TMT":2.85,"TND":1.66316,"TOP":1.854405,"TRY":2.135726,"TTD":6.43465,"TWD":30.02066,"TZS":1685.116667,"UAH":11.8597,"UGX":2569.95,"USD":1,"UYU":22.98366,"UZS":2305.953311,"VEF":6.292275,"VND":21206,"VUV":94.252501,"WST":2.298934,"XAF":484.799008,"XAG":0.05081723,"XAU":0.00078076,"XCD":2.70158,"XDR":0.649354,"XOF":485.16402,"XPF":88.20458,"YER":214.986999,"ZAR":10.71995,"ZMK":5252.024745,"ZMW":6.284713,"ZWL":322.355006}
并知道我想为每种货币添加正确的货币符号和货币名称(使用本地语言)。
有人知道像那样的货币符号列表
$
'; €
'; £
'; 我不确定,每种货币都存在登录" HTML编码(数字)"?
是否(通常)可以将本机货币名称存储在普通的JS对象中?
提前致谢。
答案 0 :(得分:9)
openexchangerates.org支持的货币的名称(英文)可在http://openexchangerates.org/api/currencies.json获取 -
{
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
/* ... */
"ZMK": "Zambian Kwacha (pre-2013)",
"ZMW": "Zambian Kwacha",
"ZWL": "Zimbabwean Dollar"
}
openexchangerates.org支持的货币的符号似乎不是由服务本身提供的。但是,https://gist.github.com/Fluidbyte/2973986提供了包含openexchangerates.com支持的大多数货币(168种货币中的124种)的符号(和其他信息)的JSON文档 -
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
/* ... */
"AFN": {
"symbol": "Af",
"name": "Afghan Afghani",
"symbol_native": "؋",
"decimal_digits": 0,
"rounding": 0,
"code": "AFN",
"name_plural": "Afghan Afghanis"
},
/* ... */
"ZMK": {
"symbol": "ZK",
"name": "Zambian Kwacha",
"symbol_native": "ZK",
"decimal_digits": 0,
"rounding": 0,
"code": "ZMK",
"name_plural": "Zambian kwachas"
}
}
如有必要,可以使用How to convert characters to HTML entities using plain JavaScript中的信息将本文档中的Unicode字符转换为HTML实体参考转义字符串。
问:是否(通常)可以将本机货币名称存储在普通的JS对象中?
虽然您显然可以在对象中存储您喜欢的任何字符串,但单数本地语言中某种货币的单数名称的想法并不是真的有道理。
例如,没有单一的母语:
答案 1 :(得分:0)
完整的JSON示例
"currency": { "AED": "United Arab Emirates dirham", "AFN": "Afghan afghani", "ALL": "Albanian lek", "AMD": "Armenian dram", "ANG": "Netherlands Antillean guilder", "AOA": "Angolan kwanza", "ARS": "Argentine peso", "AUD": "Australian dollar", "AWG": "Aruban florin", "AZN": "Azerbaijani manat", "BAM": "Bosnia and Herzegovina convertible mark", "BBD": "Barbados dollar", "BDT": "Bangladeshi taka", "BGN": "Bulgarian lev", "BHD": "Bahraini dinar", "BIF": "Burundian franc", "BMD": "Bermudian dollar", "BND": "Brunei dollar", "BOB": "Boliviano", "BRL": "Brazilian real", "BSD": "Bahamian dollar", "BTN": "Bhutanese ngultrum", "BWP": "Botswana pula", "BYN": "New Belarusian ruble", "BYR": "Belarusian ruble", "BZD": "Belize dollar", "CAD": "Canadian dollar", "CDF": "Congolese franc", "CHF": "Swiss franc", "CLF": "Unidad de Fomento", "CLP": "Chilean peso", "CNY": "Renminbi|Chinese yuan", "COP": "Colombian peso", "CRC": "Costa Rican colon", "CUC": "Cuban convertible peso", "CUP": "Cuban peso", "CVE": "Cape Verde escudo", "CZK": "Czech koruna", "DJF": "Djiboutian franc", "DKK": "Danish krone", "DOP": "Dominican peso", "DZD": "Algerian dinar", "EGP": "Egyptian pound", "ERN": "Eritrean nakfa", "ETB": "Ethiopian birr", "EUR": "Euro", "FJD": "Fiji dollar", "FKP": "Falkland Islands pound", "GBP": "Pound sterling", "GEL": "Georgian lari", "GHS": "Ghanaian cedi", "GIP": "Gibraltar pound", "GMD": "Gambian dalasi", "GNF": "Guinean franc", "GTQ": "Guatemalan quetzal", "GYD": "Guyanese dollar", "HKD": "Hong Kong dollar", "HNL": "Honduran lempira", "HRK": "Croatian kuna", "HTG": "Haitian gourde", "HUF": "Hungarian forint", "IDR": "Indonesian rupiah", "ILS": "Israeli new shekel", "INR": "Indian rupee", "IQD": "Iraqi dinar", "IRR": "Iranian rial", "ISK": "Icelandic króna", "JMD": "Jamaican dollar", "JOD": "Jordanian dinar", "JPY": "Japanese yen", "KES": "Kenyan shilling", "KGS": "Kyrgyzstani som", "KHR": "Cambodian riel", "KMF": "Comoro franc", "KPW": "North Korean won", "KRW": "South Korean won", "KWD": "Kuwaiti dinar", "KYD": "Cayman Islands dollar", "KZT": "Kazakhstani tenge", "LAK": "Lao kip", "LBP": "Lebanese pound", "LKR": "Sri Lankan rupee", "LRD": "Liberian dollar", "LSL": "Lesotho loti", "LYD": "Libyan dinar", "MAD": "Moroccan dirham", "MDL": "Moldovan leu", "MGA": "Malagasy ariary", "MKD": "Macedonian denar", "MMK": "Myanmar kyat", "MNT": "Mongolian tögrög", "MOP": "Macanese pataca", "MRO": "Mauritanian ouguiya", "MUR": "Mauritian rupee", "MVR": "Maldivian rufiyaa", "MWK": "Malawian kwacha", "MXN": "Mexican peso", "MXV": "Mexican Unidad de Inversion", "MYR": "Malaysian ringgit", "MZN": "Mozambican metical", "NAD": "Namibian dollar", "NGN": "Nigerian naira", "NIO": "Nicaraguan córdoba", "NOK": "Norwegian krone", "NPR": "Nepalese rupee", "NZD": "New Zealand dollar", "OMR": "Omani rial", "PAB": "Panamanian balboa", "PEN": "Peruvian Sol", "PGK": "Papua New Guinean kina", "PHP": "Philippine peso", "PKR": "Pakistani rupee", "PLN": "Polish złoty", "PYG": "Paraguayan guaraní", "QAR": "Qatari riyal", "RON": "Romanian leu", "RSD": "Serbian dinar", "RUB": "Russian ruble", "RWF": "Rwandan franc", "SAR": "Saudi riyal", "SBD": "Solomon Islands dollar", "SCR": "Seychelles rupee", "SDG": "Sudanese pound", "SEK": "Swedish krona", "SGD": "Singapore dollar", "SHP": "Saint Helena pound", "SLL": "Sierra Leonean leone", "SOS": "Somali shilling", "SRD": "Surinamese dollar", "SSP": "South Sudanese pound", "STD": "São Tomé and Príncipe dobra", "SVC": "Salvadoran colón", "SYP": "Syrian pound", "SZL": "Swazi lilangeni", "THB": "Thai baht", "TJS": "Tajikistani somoni", "TMT": "Turkmenistani manat", "TND": "Tunisian dinar", "TOP": "Tongan paʻanga", "TRY": "Turkish lira", "TTD": "Trinidad and Tobago dollar", "TWD": "New Taiwan dollar", "TZS": "Tanzanian shilling", "UAH": "Ukrainian hryvnia", "UGX": "Ugandan shilling", "USD": "United States dollar", "UYI": "Uruguay Peso en Unidades Indexadas", "UYU": "Uruguayan peso", "UZS": "Uzbekistan som", "VEF": "Venezuelan bolívar", "VND": "Vietnamese đồng", "VUV": "Vanuatu vatu", "WST": "Samoan tala", "XAF": "Central African CFA franc", "XCD": "East Caribbean dollar", "XOF": "West African CFA franc", "XPF": "CFP franc", "XXX": "No currency", "YER": "Yemeni rial", "ZAR": "South African rand", "ZMW": "Zambian kwacha", "ZWL": "Zimbabwean dollar" }
答案 2 :(得分:0)
查看这个json文件
https://github.com/mansourcodes/country-databases/blob/main/currency-details.json
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
"CAD": {
"symbol": "CA$",
"name": "Canadian Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "CAD",
"name_plural": "Canadian dollars"
....