Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify defining number formats for different locales #2054

Open
3 tasks done
MickL opened this issue Dec 21, 2024 · 0 comments
Open
3 tasks done

Unify defining number formats for different locales #2054

MickL opened this issue Dec 21, 2024 · 0 comments
Labels
Status: Proposal Request for comments

Comments

@MickL
Copy link

MickL commented Dec 21, 2024

Clear and concise description of the problem

At the moment number formats need to be defined for every locale, but this results in duplicate code:

numberFormats: {
    de: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
    fr: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
    es: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
  },
  datetimeFormats: {
    de: {
      date: {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
      },
    },
    fr: {
      date: {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
      },
    },
    es: {
      date: {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
      },
    },
  },

This is a simple example but imagine having 27 EU countries and defining multiple date formats and all of them are the same.

Suggested solution

Maybe something like this:

numberFormats: {
    currency: {
      style: 'currency',
      currency: 'EUR',
      locales: ['de', 'fr', 'es'],
    },
  },
  datetimeFormats: {
    date: {
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      locales: ['de', 'fr', 'es'],
    },
  },

Additionally locales could be optional: If not defined it applies to all locales.

Alternative

No response

Additional context

No response

Validations

@MickL MickL added the Status: Proposal Request for comments label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

1 participant