Skip to content

Instantly share code, notes, and snippets.

@lizzymendivil
Created February 13, 2019 12:57
Show Gist options
  • Save lizzymendivil/8be11bc8311f81487ce1899a87c38e44 to your computer and use it in GitHub Desktop.
Save lizzymendivil/8be11bc8311f81487ce1899a87c38e44 to your computer and use it in GitHub Desktop.
ngx-translate app.component.ts
import { Component } from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private translateService: TranslateService) {
const browserLanguage = translateService.getBrowserLang();
translateService.setDefaultLang('en');
translateService.use(browserLanguage);
}
switchLanguage(language: string) {
this.translateService.use(language);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment