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

t() or Trans with HTML entities #1537

Closed
hurvajs77 opened this issue Jul 26, 2022 · 6 comments
Closed

t() or Trans with HTML entities #1537

hurvajs77 opened this issue Jul 26, 2022 · 6 comments

Comments

@hurvajs77
Copy link

🐛 Bug - HTML entities aren't translated

If I use any HTML entity in JSON, so I see output as entity code, not character. Sometimes is required use a special charter as hellip, non-break space etc.

To Reproduce

{ "text": "Some text with hellip (…) - three dots as one character" }
t('text')

// or

<Trans i18nKey="text" />

Expected behavior

I expect that pure HTML will be display as real entity.

Some text with helip () - three dots as one character

Your Environment

  • runtime version: node v16.13,
  • i18next version: i.e. 11.18.0
  • os: MacOS
@adrai
Copy link
Member

adrai commented Jul 26, 2022

Did you already try the unescape option? #1529

@hurvajs77
Copy link
Author

yeah, I did.

{ "text": "u&nbps;nás" }
<Trans shouldUnescape i18nKey="text" />

The reusult is always the same u&nbsp;nás, but must be "u nás" with non-break space. - doesn't matter on shouldUnescape. The same situation when I try to use any one other HTML entity.

Primarily, I use NPM package next-i18next (wrapper above react-i18n), I've latest versions.

@hurvajs77
Copy link
Author

🤣🤣

really? I need to manually convert HTML entities? 🙈 LOL. Ok, in this case I stop using this crazy and funny package and write custom implementation based on real translation package ReactIntl.

@adrai
Copy link
Member

adrai commented Jul 27, 2022

If you're interested in having this html entities unescaped without providing a custom unescape function, why do you not contribute with a PR and extends this? https://github.com/i18next/react-i18next/blob/master/src/unescape.js

@adrai
Copy link
Member

adrai commented Jul 27, 2022

@hurvajs77 v11.18.2 should include also the helip... the according PR: #1538

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