Skip to content

Fix the en currency data - #3335

Merged
jremes-foss merged 1 commit into
faker-ruby:mainfrom
yu2971512385-ui:fix/currency-data
Oct 13, 2026
Merged

jremes-foss merged 1 commit into
faker-ruby:mainfrom
yu2971512385-ui:fix/currency-data

Conversation

@yu2971512385-ui

Copy link
Copy Markdown
Contributor

Disclosure: prepared with AI assistance (Claude Opus 5 via Claude Code) — the diff against the ISO 4217 list, the patch, the tests and this description.

What is wrong

lib/locales/en/currency.yml was taken from the ISO 4217 table some years ago and has three kinds of problem.

Rows listing two currencies were read as one entry. The second currency lost its code and its name was glued onto the first:

code name in the file currency that was dropped
INR Indian Rupee Ngultrum BTN
ZAR Rand Loti LSL
ZAR Rand Namibia Dollar NAD
HTG Gourde US Dollar — (USD already listed)
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 —

So Faker::Currency.name can return "Rand Namibia Dollar", which is not a currency, and because ZAR and INR appear three and two times, Faker::Currency.code returns them that much more often than 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 (BOV, CLF, COU, MXV, UYI, and CUC, withdrawn in 2021) stay out — the list has never held them, and 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

Six were withdrawn without one: BGN, EEK, HRK, LTL, LVL when those countries adopted the euro (2026, 2011, 2023, 2015, 2014), and XFU when the UIC franc was discontinued in 2013. SSP, in circulation since 2011, was never listed.

169 entries become 164.

Out of scope

Spelling drift against the current ISO names — AWG is Aruban Guilder where ISO now says Aruban Florin, PEN is Nuevo Sol where ISO says Sol, and nineteen more. Those are readable as they are, so I left them; happy to follow up if you want them aligned.

Tests

Two new cases in test_faker_currency.rb: codes must be unique, and no name may be another name followed by a second one. They fail on main with duplicated currency codes: INR, ZAR and names holding two currencies: Indian Rupee Ngultrum, Rand Loti, Rand Namibia Dollar, and pass here.

Full suite: 2181 tests, 281843 assertions, 0 failures, 0 errors. rubocop clean on the changed test file.

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) <noreply@anthropic.com>

@jremes-foss jremes-foss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution!

@jremes-foss
jremes-foss merged commit 6df1279 into faker-ruby:main Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants