Skip to main content
Version: 4.x.x

Switching languages

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 methods setLang and getCurrentLang.

language.component.html
<select
[value]="translateService.getCurrentLang()"
(change)="translateService.setLang($event.target.value)"
>
<option value="en">🇬🇧 English</option>
<option value="cs">🇨🇿 Česky</option>
</select>