Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngPluralize: support for HTML tags in translations? #4790

Open
ysbaddaden opened this issue Nov 5, 2013 · 24 comments
Open

ngPluralize: support for HTML tags in translations? #4790

ysbaddaden opened this issue Nov 5, 2013 · 24 comments

Comments

@ysbaddaden
Copy link

I found myself in a situation where some of the translation, and not all, must be within a strong tag. Since the ngPluralize directive uses element.text() (source) then the string is HTML escaped, and it doesn't work.

<ng:pluralize count="users.length" when="{other:'<strong>{}</strong> users'}" />

Since it may lead to XSS issues, I was wondering how to allow ngPluralize to use element.html() in some cases. If $interpolate already escapes the interpolated values, then maybe the directive could use element.html()? Or may be add an attribute like as="html" to give the user control over the HTML safeness of the translation? All it would need then is:

function ngPluralizeWatchAction(newVal) {
  if (attr.as === 'html') {
    element.html(newVal);
  } else {
    element.text(newVal);
  }
}
@samward1985
Copy link

+1

@ghost ghost assigned tbosch Jan 11, 2014
@Casperd88
Copy link

+1

7 similar comments
@guillaumesmo
Copy link

+1

@wagnerdevel
Copy link

+1

@hamsterready
Copy link

+1

@josh256
Copy link

josh256 commented May 28, 2014

+1

@xaralis
Copy link

xaralis commented Jul 24, 2014

+1

@PatrickWolleb
Copy link

+1

@jbielick
Copy link

+1

@btford btford removed the gh: issue label Aug 20, 2014
@amitport
Copy link

👍

4 similar comments
@squarecapadmin
Copy link

+1

@blair55
Copy link

blair55 commented Nov 10, 2014

+1

@scanferla
Copy link

+1

@shanecp
Copy link

shanecp commented Jan 2, 2015

+1

@imjoshholloway
Copy link

+1. In the mean time I've created a gist that I'm using in place of ngPluralize where I need HTML

@krazi3
Copy link

krazi3 commented Apr 1, 2015

+1

1 similar comment
@AshCoolman
Copy link

👍

@thicolares
Copy link
Contributor

+1

1 similar comment
@jhalley
Copy link

jhalley commented Jul 22, 2015

+1

@lgalfaso
Copy link
Contributor

Using html with pluralize should be strait-forward with a small ad-hoc directive as it is the case here
http://plnkr.co/edit/mkKt5rqYorGu4a1t93J8?p=preview

@manikanta896
Copy link

+1

2 similar comments
@nicolasmoise
Copy link

+1

@danpe
Copy link

danpe commented Nov 29, 2016

+1

@christianesperar
Copy link

christianesperar commented Jan 28, 2018

Hi, this seems a little bit late, but in case anyone still has some problem with this one, I created directives that can solve this problem. It can be found here https://github.com/christianesperar/ng-pluralize-html

You can see it in action here https://rawgit.com/christianesperar/ng-pluralize-html/master/example/github.html

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests