Replies: 5 comments 3 replies
-
This is currently not supported by design: #92 Can you solve your problem with something like this? const t = useTranslations('Global');
function getLabel(key: 'key1' | 'key2' | …) {
return t(key);
}
<BrickRenderer getLabel={getLabel} /> |
Beta Was this translation helpful? Give feedback.
-
I expressed myself incorrectly i guess.
And now for example i want to pass down the t() function with the key "Global" to the component renderer (brick renderer). Only someKey should be shown. I hope i expressed my self this time better :) |
Beta Was this translation helpful? Give feedback.
-
That's because this type doesn't work as expected: export type Translations = Awaited<ReturnType<typeof getTranslations>>; The reason why passing the If Can you tell me a bit more about your I understand that this constraint on the usage of I'll move this to a discussion for the time being, since this is currently working as expected. |
Beta Was this translation helpful? Give feedback.
-
@ayhankiz
use it like this:
Like that, everything should suggest correct typing |
Beta Was this translation helpful? Give feedback.
-
Another problem I see about passing the t as an argument, is that i18n-ally will not work properly |
Beta Was this translation helpful? Give feedback.
-
Link to page
https://next-intl-docs.vercel.app/docs/workflows/typescript
Describe the problem
My problem is following: I want to pass down the translation function as a prop, but i don't know how to achieve the type of it.
Thats my type i created so far:
This works but only if i have one key in my messages.json. If i have multiple keys it doesn't work.
I put it under docs, because i hoped that i will find a way to achieve this by reading the docs.
Beta Was this translation helpful? Give feedback.
All reactions