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

Lists within messages #1610

Open
ArtoszBart opened this issue Dec 14, 2024 · 1 comment
Open

Lists within messages #1610

ArtoszBart opened this issue Dec 14, 2024 · 1 comment
Labels
enhancement New feature or request upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)

Comments

@ArtoszBart
Copy link

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

next-intl provides a list formatting function, such as format.list(items, {type: 'conjunction'}). However, it would be great if the t() function could accept an array as an argument, allowing you to include translated text while letting next-intl handle conjunctions or disjunctions automatically.

Describe the solution you'd like

i18next already provides a good solution, as shown here.

Describe alternatives you've considered

For example, a similar solution could look like this:

en.json

{
  "list_example": "I used {listVariable, list}"
}

.ts

const listVariable = ['Next.js', 'Typescript', 'next-intl'];
t('list_example', { listVariable, type: 'conjunction' })

the output would be:

I used Next.js, TypeScript, and next-intl.
@ArtoszBart ArtoszBart added enhancement New feature or request unconfirmed Needs triage. labels Dec 14, 2024
@amannn
Copy link
Owner

amannn commented Dec 16, 2024

I agree it could be useful, but next-intl currently depends on intl-messageformat which unfortunately doesn't support this (I think because it's not spec'ed by ICU).

The alternative is:

t('list', items: format.list(items));

@amannn amannn added the upstream-issue This issue is caused by an upstream dependency (e.g. Next.js) label Dec 16, 2024
@amannn amannn removed the unconfirmed Needs triage. label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request upstream-issue This issue is caused by an upstream dependency (e.g. Next.js)
Projects
None yet
Development

No branches or pull requests

2 participants