Skip to content

Commit

Permalink
fix(service): check whether browserLang is undefined (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfilipponi authored Feb 5, 2020
1 parent 6c079e2 commit 3e0aebb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/ngx-translate/core/src/lib/translate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ export class TranslateService {
let browserLang: any = window.navigator.languages ? window.navigator.languages[0] : null;
browserLang = browserLang || window.navigator.language || window.navigator.browserLanguage || window.navigator.userLanguage;

if (typeof browserLang === 'undefined') {
return undefined
}

if (browserLang.indexOf('-') !== -1) {
browserLang = browserLang.split('-')[0];
}
Expand Down

0 comments on commit 3e0aebb

Please sign in to comment.