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:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...