Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameters in angular-translate

It'll probably be best if you translate inside the controller for this one, unless you want to pass element and minlength to the template.

Firstly you'll need inject $translate into your controller. Then to generate your message:

this.errorMessage = $translate('MINLENGTH', { element: element, value: minlength });

This method is also outlined here.

To do this in the template (outlined here):

{{ MINLENGTH | translate : { element: element, value: minlength } }}

For anyone wondering how the syntax is, for using methods to retrieve the input for translation, this worked for me:

   {{ MINLENGTH | translate : { x: table.getShownCount(), y: table.getTotalCount() } }} 

You can also use $translate.instant('MINLENGTH', { element: element, value: minlength })


You can also do this in the template like this.

<span data-translate="MINLENGTH" data-translate-values="{ element: element, value: minlength }"></span>

This worked fine for me:

{{'commisionMessage' | translate : {fee:fee} }}|

Json File

"commisionMessage": "BLA {{fee}} BLA BLA"