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

Better support for HTML tags inside translated strings #58

Open
mitar opened this issue Mar 20, 2019 · 4 comments
Open

Better support for HTML tags inside translated strings #58

mitar opened this issue Mar 20, 2019 · 4 comments

Comments

@mitar
Copy link

mitar commented Mar 20, 2019

(This is a followup to Polyconseil/vue-gettext#93.)

As an example, let's look at the following simple Vue template:

<template>
  <translate>
     XXX
     <div translate-name="NNN">foo</div>
     YYY
  </translate>
</template>

Currently this is extracted as:

msgid ""
"XXX\n"
"   <div translate-name=\"NNN\">foo</div>\n"
"   YYY"

I would propose that instead of requiring HTML to be embedded inside translation, which opens your to XSS attacks, and which makes it possible only to use standard HTML but not things like Vue components inside translations, we would parse such string in a smarter way to allow Vue library like vue-gettext to render those HTML segments through Vue.

I would suggest that the above is parsed as:

msgid "XXX %{NNN} YYY"

Because it is HTML, we can collapse whitespace. Moreover, we provide a placeholder to interpolate the internal HTML in. So in a way, only top-level text nodes would be used and everything else would be delegated to placeholder and library to fill. translate-name can be used to control the name of the placeholder (otherwise by default we could use some sequence number).

We should also support parsing the case where internal <div> is translated as well. In that case foo should become another msgId.

@mitar
Copy link
Author

mitar commented Apr 18, 2020

Why closing this? :-(

@vperron
Copy link
Contributor

vperron commented Apr 18, 2020

Because it has over one year and zero follow-up, which is our policy pertaining to old issues. I could reopen this if you plan on opening a pull request to fix it, or if anybody plusses it.

@mitar
Copy link
Author

mitar commented Apr 18, 2020

I mean, this is a requirement for the following issues to be fixed:

Which I think have some activity?

@vperron
Copy link
Contributor

vperron commented Apr 19, 2020

OK, I'll reopen it.

@vperron vperron reopened this Apr 19, 2020
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