vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Avoid duplicate code for `numberFormats` and `dateTimeFormats `

Open MickL opened this issue 1 year ago • 1 comments

Clear and concise description of the problem

Currently numberFormats and dateTimeFormats need to be set for each language separately:

numberFormats: {
    de: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
    nl: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    es: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
    fr: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
    pt: {
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
  },

This results in duplicate code for countries that share the same currency or date-time-format (common within in the EU).

Suggested solution

It would be nice to group them somehow, for example:

numberFormats: [
    {
      locales: ['de', 'nl', 'es', 'fr', 'pt'],
      currency: {
        style: 'currency',
        currency: 'EUR',
      },
    },
  ],

Or in some other way.

Alternative

No response

Additional context

No response

Validations

MickL avatar Jan 24 '24 15:01 MickL

I just came back here 9 months later, having the exact same issue. Now I have way more number and date formats and languages so the duplicate code is enormous. Is there any ETA maybe @kazupon ?

MickL avatar Oct 18 '24 16:10 MickL