core
core copied to clipboard
Translate data coming from REST API
Is there way to translate the dynamic data coming from the REST API? I saw some examples that the backend handles it sending additional headers to the request, but I wanted to check if this is possible with this lib too in the frontend side.
eg.
app.component.html
<!-- LANGUAGE SELECTOR-->
<nav>
<select (change)="changeLocale()" [(ngModel)]="selectedLanguage">
<option *ngFor="let language of languages" [value]="language.id">{{ language.title }}</option>
</select>
</nav>
<!-- HARD CODE TEXT -->
<div>{{ 'HOME.TITLE' | translate }}</div>
<div>{{ 'HOME.DESCRIPTION' | translate }}</div>
<!-- BACKEND SERVICE -->
<div *ngFor="let item of list">
<div>
{{ item.name }}
</div>
<div>
{{ item.description }}
</div>
<div>
{{ item.price }}
</div>
</div>
payload.json
"payload": [
{
"id": 1,
"name": "Strawberry",
"description": "Small and sweet",
"price": 0.99
},
...
]
How to translate the items?