4

Lets say I want to have an icon inline in the text

'Please scan the <span class="icon ion-barcode"></span> on the screen'

How would i add that to a translation with angular-translate without splitting the sentence into two parts ?

'{{ 'scan_1' | translate }} 
 <span class="icon icon-barcode"></span> 
 {{ 'scan_2' | translate }}'

....

.config(['$translateProvider', function ($translateProvider) {
  var translations = {
    en : {
      scan_1 : 'Please scan the', 
      scan_2 : 'on the screen', 
    }
  };

  $translateProvider
    .translations('en', translations.en)
    .preferredLanguage('en');
}])
3
  • This is not a scenario supported by the translation service. Why not simply copy the entire text including the <span> elements and have a translation setup for it. Commented Feb 23, 2015 at 8:19
  • The translation is interpolated as text, not HTML. If you you put html tags in the translation they will be escapes resulting in Please scan the <span class="icon ion-barcode"></span> on the screen. Commented Feb 23, 2015 at 8:30
  • possible duplicate of How to handle strings containing HTML using Angular-Translate? Commented Feb 23, 2015 at 8:32

1 Answer 1

1

This might be possible with the translate directive:

<ANY translate="{{toBeInterpolated}}"></ANY>

Have a look here and here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.