From 3e0aebbb02523b54ac9473f6bebf33f3ca3555b0 Mon Sep 17 00:00:00 2001 From: cfilipponi <42095328+cfilipponi@users.noreply.github.com> Date: Wed, 5 Feb 2020 17:09:52 +0100 Subject: [PATCH] fix(service): check whether browserLang is undefined (#1007) --- projects/ngx-translate/core/src/lib/translate.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/ngx-translate/core/src/lib/translate.service.ts b/projects/ngx-translate/core/src/lib/translate.service.ts index 9156bcec..8ea1318c 100644 --- a/projects/ngx-translate/core/src/lib/translate.service.ts +++ b/projects/ngx-translate/core/src/lib/translate.service.ts @@ -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]; }