Skip to content

Unify defining number formats for different locales #2054

Open
@MickL

Description

@MickL

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions