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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using shouldUnescape soft hyphen (­) is not unescaped #1560

Closed
Kolombiken opened this issue Oct 10, 2022 · 4 comments
Closed

When using shouldUnescape soft hyphen (­) is not unescaped #1560

Kolombiken opened this issue Oct 10, 2022 · 4 comments

Comments

@Kolombiken
Copy link

馃悰 Bug Report

When using the prop shouldUnescape ­ is not unescaped while other HTML entities like > are.

Found an old issue by @nilsmehlhorn that looks like it was closed since it has been fixed. But maybe there has been a regression?

To Reproduce

A codesandbox example forked from the old issue with updated package versions.

Expected behavior

Expected output is that ­is unescaped as a soft hyphen.

Your Environment

  • runtime version: node v16.17.0, Chrome
  • react-i18next version: 11.18.6
  • i18next version: 21.9.2
@adrai
Copy link
Member

adrai commented Oct 10, 2022

Would you like to send a Pull Request to address this? Remember to extend the existing unit tests.

@Kolombiken Kolombiken changed the title When using shouldUnescape soft hyphen (­) is not unesacped When using shouldUnescape soft hyphen (­) is not unescaped Oct 11, 2022
@Kolombiken
Copy link
Author

@adrai Yes, maybe. If I can figure out how to fix it. Need to look into it.

@nilsmehlhorn
Copy link
Contributor

In the issue #1435 and it's corresponding pull request #1529 you've mentioned it was decided to enable override of the default unescape behavior (which you can see here https://github.com/i18next/react-i18next/blob/d3247b5c232f5d8c1a154fe5dd0090ca88c82dcf/src/unescape.js) rather than adding additional HTML entities.

So, it's now possible to provide a custom unescape function which respects any HTML entities you like - I'm doing this successfully in a project since the PR was merged. Here's a test showing roughly how to put it into config:

describe('trans with custom unescape', () => {

@Kolombiken
Copy link
Author

@nilsmehlhorn This is great! 馃帀 Also a lot better than adding HTML entities to a list. Sorry for not understanding that this was the outcome from that old issue.

Maybe what could still be done is an update to the documentation with a clear example? I totally missed that this was possible. Anyway. Closing this now.

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

3 participants