3

Translation works fine until I try to translate a placeholder:

<input type="text" placeholder="{{'TASKDETAILS_LOCATION_PLACEHOLDER' | translate}}" ng-model="selectedTask.location">

Then I see encoded text:
Input after translation

Code example: http://jsfiddle.net/eq4bq0mL/5/

Is it something to do with the sanitization? Any solution to this?

update

I played with the sanitization strategy following @AWolf suggestion. There seems to be few options "escape", "sanitize", "sanitizeParameters":

$translateProvider.useSanitizeValueStrategy('sanitize');

sanitizeParameters seems to work but I am not sure whether it's safe? Are there any downsides of using it as a strategy? The API docs don't seem to elaborate on that.

Guy
  • 12,488
  • 16
  • 79
  • 119
  • Please add js code to see what could be the problem. With-out code no one can help you with your problem. Please have a look at this [fiddle](http://jsfiddle.net/awolf2904/eq4bq0mL/) for angular translate demo. – AWolf Sep 23 '15 at 10:51
  • Yes, seems to be a sanitization issue. Please have a look at this [fiddle](http://jsfiddle.net/Lgtgys4k/) and then the German letter `ü`. Will be encoded with `ngSanitize`. Your question is probably a duplicate, see this [SO question](http://stackoverflow.com/questions/31002499/angular-translate-sanitisation-fails-with-utf-characters). – AWolf Sep 23 '15 at 11:10
  • This seems to work. http://jsfiddle.net/Lgtgys4k/3/ I wonder how safe it is. – Guy Sep 23 '15 at 12:00
  • I think both (`sanitizeParameters` or `escape`) are safe because you can't inject js or html into your code because it will be escaped and treated as text. Try to add html tags or script into your translation. It won't render/execute. – AWolf Sep 23 '15 at 12:09

1 Answers1

1

My problem was solved by using the "escape" strategy since "sanitize" seems to have a bug in your case.

$translateProvider.useSanitizeValueStrategy('escape');

These two threads justify the workaround

https://github.com/angular-translate/angular-translate/issues/1101

https://github.com/angular-translate/angular-translate/issues/1081

Jenninha
  • 1,357
  • 2
  • 20
  • 42