Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Intl.NumberFormat Get the Currency Code from a Dynamic Locale?

I am struggling to find a good way to get the Currency Code for Intl.NumberFormat from my locale.

We have the ability for the user to change locale at any time. I need a way to retrieve the currency code based on the selected locale so that I can format appropriately.

let chosenLocale = appSettings.LocaleKey; //Could be anything user chooses en-US, ja-JP, etc..

// THIS DOES NOT EXIST, DOES ANY SUCH MAPPING, LOOKUP, OR LIST EXIST?
let currencyBasedOnLocale = GetCurrencyCodeFromLocale(chosenLocale); 

// WOULD BE COOL IF THERE WAS THIS FOR ALL KNOWN CURRENCIES:
// var localeCurrencyLookup = { "en-US": "USD", "ru-RU" : "RUB", "en-GB" : "GBP", etc... }
// THEN I COULD DO THIS:
// let currencyBasedOnLocale = localeCurrencyLookup[chosenLocale] || "USD"; 

var formatter = new Intl.NumberFormat(chosenLocale, {
    style: 'currency',
    currency: currencyBasedOnLocale
});
return formatter.format(value);

So does anyone know if such a mapping of locales to currency codes exist? Or is there some other way I can find the currency code based on the locale? I feel like this is a huge oversite to not have a locale to currency mapping. Perhaps most sites only support a few locales, leaving the developer to hash it out manually. I do not mind typing out a json lookup mapping object, but I do not even know where to go to see which locales map to which currency code.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!