Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created September 14, 2018 12:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lydemann/3b918767014858ab778ac71a6b2a64a4 to your computer and use it in GitHub Desktop.
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(translate: TranslateService) {
translate.addLangs(['en', 'da']);
translate.setDefaultLang('en');
const browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/en|da/) ? browserLang : 'en');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment