import { Component , OnInit } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; @ Component ( { selector : 'app-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent implements OnInit { ngOnInit ( ) { this . translate . use ( 'en' ) ; } private initModel ( ) { } constructor ( private translate ) { translate . setDefaultLang ( 'en' ) ; } switchLanguage ( language ) { this . translate . use ( language ) ; } }