From fa0d41e604cae4d4018a71dc5039d6c62d45d433 Mon Sep 17 00:00:00 2001 From: yu2971512385-ui <287936273+yu2971512385-ui@users.noreply.github.com> Date: Mon, 12 Oct 2026 22:39:50 +0800 Subject: [PATCH] Fix the en currency data Three kinds of problem in lib/locales/en/currency.yml, all from the ISO 4217 table it was taken from years ago. Rows where a country uses two currencies were read as one entry, so the second currency lost its code and its name was glued onto the first: INR "Indian Rupee Ngultrum" BTN was dropped ZAR "Rand Loti" LSL was dropped ZAR "Rand Namibia Dollar" NAD was dropped HTG "Gourde US Dollar" PAB "Balboa US Dollar" SVC "El Salvador Colon US Dollar" BOB "Boliviano Mvdol" CLP "Chilean Peso Unidades de fomento" COP "Colombian Peso Unidad de Valor Real" CUP "Cuban Peso Peso Convertible" MXN "Mexican Peso Mexican Unidad de Inversion (UDI)" UYU "Peso Uruguayo Uruguay Peso en Unidades Indexadas" Faker::Currency.name could therefore return "Rand Namibia Dollar", which is not a currency, and ZAR and INR were drawn two and three times as often as any other code. Each name now holds one currency, and BTN, LSL and NAD are listed in their own right; the fund and index units that shared the other rows stay out, as they are not currencies anyone holds. Eight codes have a successor: ANG -> XCG 2025-03-31 SLL -> SLE 2022-04-01 BYR -> BYN 2016-07-01 STD -> STN 2018-01-01 MRO -> MRU 2018-01-01 VEF -> VES 2018-08-20 ZMK -> ZMW 2013-01-01 ZWL -> ZWG 2024-04-05 and six were withdrawn without one: BGN, EEK, HRK, LTL and LVL when those countries adopted the euro, and XFU when the UIC franc was discontinued in 2013. SSP, in circulation since 2011, was never listed. Spelling drift against the current ISO names (AWG "Aruban Guilder" for "Aruban Florin", PEN "Nuevo Sol" for "Sol", and nineteen more) is left alone here. Co-Authored-By: Claude Opus 5 (1M context) --- lib/locales/en/currency.yml | 68 ++++++++++------------- test/faker/default/test_faker_currency.rb | 18 ++++++ 2 files changed, 47 insertions(+), 39 deletions(-) diff --git a/lib/locales/en/currency.yml b/lib/locales/en/currency.yml index 444a2032a0..4ef66902c5 100644 --- a/lib/locales/en/currency.yml +++ b/lib/locales/en/currency.yml @@ -6,7 +6,6 @@ en: - AFN - ALL - AMD - - ANG - AOA - ARS - AUD @@ -15,7 +14,6 @@ en: - BAM - BBD - BDT - - BGN - BHD - BIF - BMD @@ -23,8 +21,9 @@ en: - BOB - BRL - BSD + - BTN - BWP - - BYR + - BYN - BZD - CAD - CDF @@ -40,7 +39,6 @@ en: - DKK - DOP - DZD - - EEK - EGP - ERN - ETB @@ -57,13 +55,11 @@ en: - GYD - HKD - HNL - - HRK - HTG - HUF - IDR - ILS - INR - - INR - IQD - IRR - ISK @@ -83,8 +79,7 @@ en: - LBP - LKR - LRD - - LTL - - LVL + - LSL - LYD - MAD - MDL @@ -93,13 +88,14 @@ en: - MMK - MNT - MOP - - MRO + - MRU - MUR - MVR - MWK - MXN - MYR - MZN + - NAD - NGN - NIO - NOK @@ -125,10 +121,11 @@ en: - SEK - SGD - SHP - - SLL + - SLE - SOS - SRD - - STD + - SSP + - STN - SVC - SYP - SZL @@ -146,7 +143,7 @@ en: - USD - UYU - UZS - - VEF + - VES - VND - VUV - WST @@ -158,8 +155,8 @@ en: - XBC - XBD - XCD + - XCG - XDR - - XFU - XOF - XPD - XPF @@ -167,16 +164,13 @@ en: - XTS - YER - ZAR - - ZAR - - ZAR - - ZMK - - ZWL + - ZMW + - ZWG name: - UAE Dirham - Afghani - Lek - Armenian Dram - - Netherlands Antillian Guilder - Kwanza - Argentine Peso - Australian Dollar @@ -185,32 +179,31 @@ en: - Convertible Marks - Barbados Dollar - Taka - - Bulgarian Lev - Bahraini Dinar - Burundi Franc - Bermudian Dollar (customarily known as Bermuda Dollar) - Brunei Dollar - - Boliviano Mvdol + - Boliviano - Brazilian Real - Bahamian Dollar + - Ngultrum - Pula - - Belarussian Ruble + - Belarusian Ruble - Belize Dollar - Canadian Dollar - Congolese Franc - Swiss Franc - - Chilean Peso Unidades de fomento + - Chilean Peso - Yuan Renminbi - - Colombian Peso Unidad de Valor Real + - Colombian Peso - Costa Rican Colon - - Cuban Peso Peso Convertible + - Cuban Peso - Cape Verde Escudo - Czech Koruna - Djibouti Franc - Danish Krone - Dominican Peso - Algerian Dinar - - Kroon - Egyptian Pound - Nakfa - Ethiopian Birr @@ -227,13 +220,11 @@ en: - Guyana Dollar - Hong Kong Dollar - Lempira - - Croatian Kuna - - Gourde US Dollar + - Gourde - Forint - Rupiah - New Israeli Sheqel - Indian Rupee - - Indian Rupee Ngultrum - Iraqi Dinar - Iranian Rial - Iceland Krona @@ -253,8 +244,7 @@ en: - Lebanese Pound - Sri Lanka Rupee - Liberian Dollar - - Lithuanian Litas - - Latvian Lats + - Loti - Libyan Dinar - Moroccan Dirham - Moldovan Leu @@ -267,16 +257,17 @@ en: - Mauritius Rupee - Rufiyaa - Kwacha - - Mexican Peso Mexican Unidad de Inversion (UDI) + - Mexican Peso - Malaysian Ringgit - Metical + - Namibia Dollar - Naira - Cordoba Oro - Norwegian Krone - Nepalese Rupee - New Zealand Dollar - Rial Omani - - Balboa US Dollar + - Balboa - Nuevo Sol - Kina - Philippine Peso @@ -298,8 +289,9 @@ en: - Leone - Somali Shilling - Surinam Dollar + - South Sudanese Pound - Dobra - - El Salvador Colon US Dollar + - El Salvador Colon - Syrian Pound - Lilangeni - Baht @@ -314,9 +306,9 @@ en: - Hryvnia - Uganda Shilling - US Dollar - - Peso Uruguayo Uruguay Peso en Unidades Indexadas + - Peso Uruguayo - Uzbekistan Sum - - Bolivar Fuerte + - Bolivar Soberano - Dong - Vatu - Tala @@ -328,8 +320,8 @@ en: - European Unit of Account 9(E.U.A.-9) - European Unit of Account 17(E.U.A.-17) - East Caribbean Dollar + - Caribbean Guilder - SDR - - UIC-Franc - CFA Franc BCEAO - Palladium - CFP Franc @@ -337,10 +329,8 @@ en: - Codes specifically reserved for testing purposes - Yemeni Rial - Rand - - Rand Loti - - Rand Namibia Dollar - Zambian Kwacha - - Zimbabwe Dollar + - Zimbabwe Gold symbol: - HK$ - Ft diff --git a/test/faker/default/test_faker_currency.rb b/test/faker/default/test_faker_currency.rb index 905afb4643..71bd212452 100644 --- a/test/faker/default/test_faker_currency.rb +++ b/test/faker/default/test_faker_currency.rb @@ -15,6 +15,24 @@ def test_code assert_match(/[A-Z]{3}/, @tester.code) end + def test_codes_are_unique + codes = I18n.translate('faker.currency.code', locale: :en) + duplicates = codes.tally.select { |_code, count| count > 1 }.keys + + assert_empty duplicates, "duplicated currency codes: #{duplicates.join(', ')}" + end + + def test_names_name_a_single_currency + names = I18n.translate('faker.currency.name', locale: :en) + # Rows of the ISO 4217 table where a country uses two currencies used to be + # read as one entry, leaving names such as 'Rand Namibia Dollar'. + glued = names.select do |name| + names.any? { |other| other != name && name.start_with?("#{other} ") } + end + + assert_empty glued, "names holding two currencies: #{glued.join(', ')}" + end + def test_symbol assert_instance_of String, @tester.symbol end