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

Support arrays of namespaces #646

Closed
Goldziher opened this issue Nov 18, 2023 · 1 comment
Closed

Support arrays of namespaces #646

Goldziher opened this issue Nov 18, 2023 · 1 comment
Labels
enhancement New feature or request unconfirmed Needs triage.

Comments

@Goldziher
Copy link

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

The issue is how to reuse translations efficiently. Currently only a single namespace can be used by useTranslations, which means we cannot have shared namespaces.

Describe the solution you'd like

const t = useTranslations("namespace1", "namespace2", "namespace3")

Describe alternatives you've considered

All alternative libraries support this. The issue they have is bad integration with next. But this feature is really really important.

@Goldziher Goldziher added enhancement New feature or request unconfirmed Needs triage. labels Nov 18, 2023
@amannn
Copy link
Owner

amannn commented Nov 20, 2023

Thank you for the report, I definitely understand your request!

This has been discussed a few times before, the latest being #217.

There are currently no plans to support this because:

  1. It would make the TypeScript integration significantly more difficult (if possible at all)
  2. It increases the API surface for something that can already be achieved today (useTranslations()—i.e. no namespace), possibly getting in the way of a potential feature in the future
  3. It introduces ambiguity which message to resolve to when there's overlap (e.g. ns1.title and ns2.title)

The structuring messages section in the docs has more information on this topic.

As mentioned, I understand the request, but I think this API is for the time being not a good direction for next-intl, especially since there are escape hatches.

Hope this helps!

@amannn amannn closed this as completed Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request unconfirmed Needs triage.
Projects
None yet
Development

No branches or pull requests

2 participants