Replies: 1 comment
-
|
For any translations that are rendered as part of a React app, Translations are part of your rendering output, therefore they should be used in combination with a component. If you have a utility function that for example generates errors, you can still return an error code and run unit tests on that. For anything that is inbetween, you could still consider using a hook that calls I'll move this to a discussion … |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Since the locale can be read from the cookie or other means, and messages can be imported it would be nice to re-use next-intl utility functions in non-react components. This prevent people from being forced to pollute react code which otherwise could have been extracted out as plain JS function and unit tested on its own.
Describe the solution you'd like
Essentially similar to https://formatjs.github.io/docs/react-intl/api/#createintl or similar to how the next/server counterpart APIs work, but for the client.
Describe alternatives you've considered
Passing functions like format.number or format.dateTime around. Or using Intl.XXX directly.
Beta Was this translation helpful? Give feedback.
All reactions