piątek, 20 kwietnia 2018

How to determine user browser language in JHipster

In navbar.component.ts add:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
findBrowserLanguage() {
    let browserLang = navigator.language;
      switch (browserLang) {
        case 'pl-PL': {
          browserLang = 'pl';
          this.changeLanguage(browserLang);
          break;
        }
       }
  }

and in ngOnInit() fuction add:

1
this.findBrowserLanguage();


Brak komentarzy:

Prześlij komentarz