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

shouldUnescape prop to <Trans> tag doesn't escape all HTML entities #1701

Closed
getsnoopy opened this issue Dec 16, 2023 · 1 comment
Closed

Comments

@getsnoopy
Copy link

馃悰 Bug Report

It seems like despite specifying the shouldUnescape prop to the <Trans> tag, it doesn't work with most HTML entities. Upon looking into the source code and some related issues (#1435 and #1560), it seems like it only supports an arbitrary subset of entities, and when it doesn't support the ones I'm using, I have to provide my own unescape function to interpret those symbols. This is not at all ideal; the docs make it seem like it will "just work", which is how it should be anyway.

To Reproduce

The JSX code:

<Trans t={t} i18nKey="entity_rich_text" shouldUnescape={true}></Trans>

The translation JSON file:

{
    "entity_rich_text": "3 &times; 3 = 9"
}

This renders as 3 &times; 3 = 9.

Expected behaviour

It should render as 3 脳 3 = 9.

Why doesn't the library just pass through all HTML entities to the browser as-is, and let the browser handle them when the shouldUnescape parameter is enabled?

Your Environment

  • runtime version: Node v14.21.3
  • i18next version: 15.1.1
  • os: Linux
@adrai
Copy link
Member

adrai commented Dec 16, 2023

shouldUnescape was introduced to only work for specific characters.
If you think that needs to be extended, feel free to provide a PR.

@adrai adrai closed this as completed Feb 17, 2024
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