ngx-translate: Translate strings in html

Source: https://stackoverflow.com/questions/50027311/ngx-translate-translate-strings-in-html

<label for="user-terms" [innerHTML]="'i-agree' | translate: {termLink: 'javascript:void(0)'}"></label>


This is how you can use parametric translation with filters:
// define translation with parameter
'TRANSLATION_KEY': '{{days}} days'

// use it in template
<span>{{ 'TRANSLATION_KEY' | translate: { days: followUpInDays | positiveNumber } }}</span>
If you want to have the whole sentence as a translation (including the HTML), you will need to use innerHTML property binding:
// define translation with parameter
'TRANSLATION_KEY': 'Follow-up is <span class="{{className}}">{{days}} days</span> past due'

// use it in template
<span *ngIf="Days < 0 && !shortSentence"
      [innerHTML]="'TRANSLATION_KEY' | translate: { className: (highlightContent ? 'font-bold' : ''), days: followUpInDays | positiveNumber }"> </span>

Không có nhận xét nào:

Is it okay to use both fetchpriority="high" and loading="eager" in img tag?

 https://stackoverflow.com/questions/77744344/is-it-okay-to-use-both-fetchpriority-high-and-loading-eager-in-img-tag Yes Fetchpriority and l...