You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`defaultTranslationValues` allow to share global values to be used in
messages across your app. The most common case are shared rich text
elements (e.g. `b: (chunks) => <b>{chunks}</b>`).
However, over time this feature has shown drawbacks:
1. We can't serialize them automatically across the RSC boundary (see
#611)
2. They get in the way of type-safe arguments (see
#410)
Due to this, the feature will be deprecated and the docs will suggest a
better alternative for common tags in rich text that doesn't have the
limitations mentioned above ([updated
docs](https://next-intl-docs-git-feat-deprecate-defaulttrans-f52ebe-next-intl.vercel.app/docs/usage/messages#rich-text-reuse-tags)).
Shared values don't get a direct replacement from `next-intl`, but
should be handled as part of your app logic (e.g. a shared module, React
Context, etc.).
**Note**: #410 can not be
implemented immediately as part of this, as long as
`defaultTranslationValues` are still available (even if deprecated).
Instead, this feature could be added as part of the next major release.
Contributes to #611
Copy file name to clipboardexpand all lines: docs/pages/docs/usage/messages.mdx
+40-3
Original file line number
Diff line number
Diff line change
@@ -333,7 +333,7 @@ t('message'); // "Escape curly braces with single quotes (e.g. {name})"
333
333
334
334
## Rich text
335
335
336
-
You can format rich text with custom tags and map them to React components:
336
+
You can format rich text with custom tags and map them to React components via `t.rich`:
337
337
338
338
```json filename="en.json"
339
339
{
@@ -351,9 +351,46 @@ t.rich('message', {
351
351
Tags can be arbitrarily nested (e.g. `This is <important><very>very</very> important</important>`).
352
352
353
353
<Detailsid="rich-text-reuse-tags">
354
-
<summary>How can I reuse a tag across my app?</summary>
354
+
<summary>How can I reuse tags across my app?</summary>
355
355
356
-
If you want to use the same tag across your app, you can configure it via [default translation values](/docs/usage/configuration#default-translation-values).
356
+
Common tags for rich text that you want to share across your app can be defined in a shared module and imported where relevant for usage with `t.rich`.
357
+
358
+
A convenient pattern is to use a component that provides common tags via a render prop:
0 commit comments