Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options.react.unescape is not consistently called for all values #1657

Closed
KiwiKilian opened this issue Jul 31, 2023 · 2 comments
Closed

options.react.unescape is not consistently called for all values #1657

KiwiKilian opened this issue Jul 31, 2023 · 2 comments

Comments

@KiwiKilian
Copy link

KiwiKilian commented Jul 31, 2023

🐛 Bug Report

unescape is not called consistently on all translation strings, when used with Trans and shouldUnescape prop.

To Reproduce

Here is a codesandbox demonstrating the bug.

The i18n setup looks like this:

i18n.use(initReactI18next).init({
  resources: {
    de: {
      translation: {
        test1: "Vertrauens­kennwert",
        test2: "Geschwindigkeits­messung"
      }
    }
  },
  lng: 'de',
  fallbackLng: "de",

  interpolation: {
    escapeValue: false
  },

  react: {
    unescape: (text) => {
      console.log(text);

      return text.replace("­", "\u00AD");
    }
  }
});

We translate like this:

<>
  <Trans shouldUnescape={true} i18nKey="test1" />
  <Trans shouldUnescape={true} i18nKey="test2" />
</>

Resulting in the following (visible) output:

Vertrauens&shy;kennwert
Geschwindigkeits­messung

Through the console.log in the options.react.unescape function it's obvious, the function is never called for Vertrauens&shy;kennwert, but only for Geschwindigkeits&shy;messung.

Bildschirmfoto 2023-07-31 um 13 41 37

Expected behavior

options.react.unescape should be called for every values. In this example it should be twice and the visible HTML output should be:

Vertrauenskennwert
Geschwindigkeits­messung

Your Environment

  • runtime version: Chromium 115
  • i18next version: 23.4.1
  • react-i18next version: 13.0.2
  • os: Mac
adrai added a commit that referenced this issue Jul 31, 2023
@adrai
Copy link
Member

adrai commented Jul 31, 2023

v13.0.3 should address this

@KiwiKilian
Copy link
Author

Thanks @adrai! #1657 fixed it indeed 👍.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants