-
Notifications
You must be signed in to change notification settings - Fork 21
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
Why are escaped character later unescaped? #36
Comments
Yes this is indeed intended. My goal for the extracted messages is to match the string in the source code as best as possible. If a developer writes a string containing That said I just noticed that the current implementation doesn't handle strings actually containing I will look into adding an option to escape HTML entities in the same way If you don't mind not having entities in your translations, you might also want to consider changing your runtime code to match the behavior of the extractor. |
@lukasgeiter yeah I'm not sure there is any easy way to do this because of how parse5 works. It is possible parse5 has an option to not change the original text but that would be necessary. Also changing the runtime code to match the behaviour is not possible. Currently this completely breaks translating strings with The bottom line is that I can't change the runtime behaviour of web browsers. |
I should have noted my workaround for the time being will be that I have to convert |
The workaround you mention is precisely what I meant by changing your runtime code. I understand that this is not an optimal solution for you. I will definitely add an option for this in the future. |
Ok thanks, that makes sense. |
gettext-extractor/src/html/utils.ts
Line 20 in cea9a47
I am trying to debug an issue where I basically can't match translation keys for HTML with HTML entities like
&
in it. It brought me to the above line of code which seems problematic.In my use case I'm translating an element at runtime using
element.innerHTML
usinginnerText
is not practical because some translations may actually require the HTML to be part of the translation like with a hyperlink.As a result the
innerHTML
has the entity as&
but the key is forced to be&
by the extractor so they can never match.Is this intended. Could it be made an optional capability instead?
The text was updated successfully, but these errors were encountered: