locales.js 599 B

12345678910111213141516171819
  1. /**
  2. * Add
  3. * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation | numbering-system tags}
  4. * to locale identifiers
  5. *
  6. * @internal
  7. */
  8. export function getNumberFormatLocales(locales, { numberingSystem }) {
  9. if (!Array.isArray(locales))
  10. locales = [locales];
  11. return numberingSystem
  12. ? locales
  13. .map(lc => {
  14. const ext = lc.indexOf('-u-') === -1 ? 'u-nu' : 'nu';
  15. return `${lc}-${ext}-${numberingSystem}`;
  16. })
  17. .concat(locales)
  18. : locales;
  19. }