-
-
Notifications
You must be signed in to change notification settings - Fork 321
Description
Is your feature request related to a problem? Please describe.
These three config options accept functions and can therefore not be serialized currently:
Due to this, we can't automatically pass them from an RSC render to the client side.
It might be worth investigating serializable alternatives, to avoid this.
Describe the solution you'd like
defaultTranslationValues
Maybe a better option could be to deprecate the option altogether and ask users to share values e.g. via a component:
function Markup() {
const t = useTranslations('Markup');
return <RichText>{components => t('markup', components)}</RichText>
}
function RichText({children}) {
return children({
b: (chunks: ReactNode) => <b>{chunks}</b>
});
}
… or imports:
// defaultRichTextComponents.tsx
export default {
b: (chunks: ReactNode) => <b>{chunks}</b>
}
// Markup.tsx
import defaultRichTextComponents from './defaultRichTextComponents';
function Markup() {
const t = useTranslations('Markup');
return t.rich('markup', defaultRichTextComponents);
}
As a nice side effect, this would allow us to statically type the arguments of a given ICU string (see #410), since there are no potential global values floating around.
Another benefit could be to remove ambiguity between values that should be used for t.rich
and t.markup
(see #1181).
onError
See #1285
getMessageFallback
See #1285
Alternatives:
- An ICU message like
MISSING: {namespace}.{key}
? - Deprecate the feature completely?
Describe alternatives you've considered
NextIntlClientProvider
can be added in a client-side module graph to configure the non-serializable config options, see the docs.