Skip to main content
Version: 5.x.x

Switching language (Angular)

For language management, use TranslationService.

language.component.ts
import { Component } from '@angular/core';
import { TranslateService } from '@tolgee/ngx';

@Component({
...
})
export class AppComponent {
constructor(public translateService: TranslateService) {}
...
}

Then in template use changeLanguage method and languageAsync property from TranslateService.

language.component.html
<select
[value]="translateService.languageAsync | async"
(change)="translateService.changeLanguage($event.target.value)"
>
<option value="en">­čçČ­čçž English</option>
<option value="cs">­čçĘ­čç┐ ─îesky</option>
</select>

Read more about Language change, detection and storage