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 for returnObjects #84

Closed
prabu-ssb opened this issue Jan 31, 2022 · 1 comment
Closed

Support for returnObjects #84

prabu-ssb opened this issue Jan 31, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@prabu-ssb
Copy link

prabu-ssb commented Jan 31, 2022

Current Behaviour
At the moment trying to resolve a key which has an array as its value throws a MISSING_MESSAGE (plus INSUFFICIENT_PATH) error.

Feature Requested
Support for returnObjects: true. At its most basic level, arrays, but will be great if it can support objects too. If the message bundle has --

{
  "items": [
    "item1",
    "item2"
  ]
}

then it should be possible to retrieve the list of translations for the key

const t = useTranslations('bundle');
const items = t('items',  { returnObjects: true });
// => [ "item1", "item2" ]

This feature is provided currently by next-i18next, next-translate etc., but next-intl seems to be much easier to setup and use. Something like this would be very handy for large scale applications like ours.

@prabu-ssb prabu-ssb added the enhancement New feature or request label Jan 31, 2022
@amannn
Copy link
Owner

amannn commented Feb 1, 2022

Hi @prabu-ssb,

thanks for your report! You can use the t.raw API for this.

@amannn amannn closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants