import { Component , ViewEncapsulation } from '@angular/core' ; import { TranslateService } from '@ngx-translate/core' ; @ Component ( { encapsulation : ViewEncapsulation . None , selector : 'st-app' , styleUrls : [ './app.styles.scss' ] , templateUrl : './app.template.html' } ) export class AppComponent { constructor ( translate ) { let lang = navigator . language . split ( '-' ) [ 0 ] ; lang = /(es|en)/gi . test ( lang ) ? lang : 'en' ; translate . setDefaultLang ( 'en' ) ; translate . use ( lang ) ; } }