Search code examples
angularjsinternationalizationangular-translate

I18n in angularjs


I18n key:

"step1.download":"{{n0}} Download {{n1}} Some text."

In my html:

<span translate=step1.download translate-values="{ n0: '{{info0}}', n1: '{{info1}}'}"></span>

In my controller:

$scope.download = function(){
        alert("fun executed");
        };
$scope.info0="<button ng-click=download()>";
$scope.info1="</button>";

I am getting an error that download function is not defined, I think because html parsed before angular compilation, so is there any way I can solve this problem. Alternatives solutions are also appreciated.


Solution

  • In html use "translate-compile" like this:

    <span translate="step1.download" translate-compile translate-values="{ n0: '{{info0}}', n1: '{{info1}}'}"></span>
    

    Worked with my case, it may depends on what translator you are using.It will work if you use "angular-translate.js".