angular-translate sanitisation fails with UTF characters

All we need is an easy explanation of the problem, so here it is.

On Angular 1.3.x with latest version of angular-translate. Using $sanitize it seems there are problems when using filter or service directly, but it works when using the directive.


Here is an example:

var myApp = angular.module('myApp', [ 'pascalprecht.translate', 'ngSanitize' ]);

myApp.config(function($translateProvider) {
    $translateProvider.translations('en', {
        UTF: 'öéü',

myApp.controller("myCtrl", function($scope, $translate) {
    $translate("UTF").then(function(trans) {
        $scope.UTFCTRL = trans;
<script src=""></script>
<script src=""></script>
<script src=""></script>

<div ng-app="myApp" ng-controller="myCtrl">
        Wrong: <h1>{{ 'UTF' | translate }}</h1>
        Ok: <h1 translate="UTF"></h1>
        Wrong: <h1>{{ UTFCTRL }}</h1>

On jsfiddle:

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

At the moment, you have two options:

  1. Use the strategy sanitizeParameters which will only sanitize the dynamic parameters, but not the actual translation (template). If you have the translation under control (but not the dynamic values), this will work.
  2. Use the strategy escape (or escapeParameters) which does not use sanitization but escaping.

Disclaimer: I’m co-maintaining angular-translate.

Edit (12.01.2016): I’d created this matrix overview of all variants.

Method 2

As said in gitHub issue

Using sce solved the issue


Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply