I18s
To use this component, you need to include the following code in your HTML document, where you want the translated text to appear:
In the i18s folder, you should add the translation strings for different languages. For example, in ru.json, you can have:
{
"Inbox": "Входящие",
"tab1": {
"tabName": "Первая закладка",
"invite": "Сейчас вы выбрали {{lang}}"
}
}
And in en.json, you can have:
"Inbox": "Inbox",
"tab1": {
"tabName": "Tab One goes here",
"invite": "Now you have selected {{lang}}"
}
To translate to English, you can use the following translation function:
component
import { TranslateService } from '@ngx-translate/core';
constructor(private translate: TranslateService) {}
ngOnInit() {
this.translate.get('FrontPage').subscribe((translated: string) => { // /Получить локализованные запись
this.pageTitle = translated;
});
}
this.translate.setTranslation('en', { // Добавить запись в локаль на ленту
'tab1.getStarted': 'Get Started', // add this
'someProperty': 'We can use translations in {{var}}' // 3
});
HTML
<ion-label>{{ "Inbox" | translate }}</ion-label>
<p translate [translateParams]="{ lang: language }">tab1.invite</p> <!-- add this -->
This will display "Inbox" in English.