Skip to content

Commit

Permalink
fix for when passed services are null, should address #296
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Dec 9, 2024
1 parent be02df9 commit 0cd29a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 8.0.2

- fix for when passed services are null, should address [296](https://github.com/i18next/i18next-browser-languageDetector/issues/296)

### 8.0.1

- some environments, throws when accessing document.cookie
Expand Down
3 changes: 2 additions & 1 deletion i18nextBrowserLanguageDetector.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@
}
};

// some environments, throws when accessing document.cookie
let canCookies = false;
try {
// eslint-disable-next-line no-unused-expressions
Expand Down Expand Up @@ -375,7 +376,7 @@
}
});
detected = detected.map(d => this.options.convertDetectedLanguage(d));
if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
return detected.length > 0 ? detected[0] : null; // a little backward compatibility
}
cacheUserLanguage(lng) {
Expand Down
2 changes: 1 addition & 1 deletion i18nextBrowserLanguageDetector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Browser {

detected = detected.map((d) => this.options.convertDetectedLanguage(d));

if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
return detected.length > 0 ? detected[0] : null; // a little backward compatibility
}

Expand Down

0 comments on commit 0cd29a8

Please sign in to comment.