Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

278
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda