From 5fff8defc8b7969d1262774334eb10e1e0cab9fd Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sun, 13 Feb 2022 12:50:26 +0100 Subject: [PATCH] docs: Clarify config for custom interpolation suffix/prefix (#1681) 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 --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index b6f22244..6a3d1cc8 100644 --- a/README.md +++ b/README.md @@ -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)