amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.37k stars 214 forks source link

Same defaults for date-, time-, number- and list formatting for values in messages and when used through `format.*` #1347

Open amannn opened 1 week ago

amannn commented 1 week ago

Is your feature request related to a problem? Please describe.

By default, no global formats are available via format.* calls. However, for consumption in messages, a few defaults are available through intl-messageformat (source).

Describe the solution you'd like

Ideally, we'd support the same defaults across both options.

The options I can currently think of are:

  1. Importing formats from intl-messageformat for local consumption (big downside: pulls in the whole dependency, so not really an option).
  2. Re-defining the formats for both places (downside: duplication with intl-messageformat)
  3. Using no defaults in either place
  4. After https://github.com/amannn/next-intl/pull/705, we'll get rid of intl-messageformat at runtime and also gain more control over aspects like defaults, so we could consider supporting the same defaults for both APIs without duplication

I'm currently favoring (3), but this would be a breaking change.

Describe alternatives you've considered

User has to define all relevant formats in user space. These apply to either functionality.