Skip to content

Commit

Permalink
docs: Clarify config for custom interpolation suffix/prefix (#1681)
Browse files Browse the repository at this point in the history
It took me a while to figure out how to get a custom
interpolation prefix/suffix to work.

I think it's a little unintuitive that changing an option
that relates to how the text inside the translation files
is structured has a knock-on effect to how files are loaded.

After doing some digging, I came across #1090 that clarifies
the issue, but I feel it's worth putting this in the README.

This PR does that. It's not much, but I hope you find it useful.

Co-authored-by: Isaac Hinman <[email protected]>
  • Loading branch information
joostdecock and isaachinman authored Feb 13, 2022
1 parent 606a425 commit 5fff8de
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,27 @@ const Component = () => {
}
```

#### Custom interpolation prefix/suffix

By default, i18next uses `{{` as prefix and `}}` as suffix for [interpolation](https://www.i18next.com/translation-function/interpolation).
If you want/need to override these interpolation settings, you **must** also specify an alternative `localeStructure` setting that matches your custom prefix and suffix.

For example, if you want to use `{` and `}` the config would look like this:

```js
{
i18n: {
defaultLocale: 'en',
locales: ['en', 'nl'],
},
interpolation: {
prefix: '{',
suffix: '}',
},
localeStructure: '{lng}/{ns}',
}
```

## Migration to v8

To migrate from previous versions to the version 8, check out the [v8-migration guide](https://github.com/isaachinman/next-i18next/tree/master/docs/v8-migration.md)
Expand Down

1 comment on commit 5fff8de

@vercel
Copy link

@vercel vercel bot commented on 5fff8de Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.