Gathering detailed insights and metrics for i18next-browser-languagedetector
Gathering detailed insights and metrics for i18next-browser-languagedetector
Gathering detailed insights and metrics for i18next-browser-languagedetector
Gathering detailed insights and metrics for i18next-browser-languagedetector
@types/i18next-browser-languagedetector
Stub TypeScript definitions entry for i18next-browser-languagedetector, which provides its own types definitions
@ryancavanaugh/i18next-browser-languagedetector
Type definitions for i18next-browser-languagedetector 0.0.14 from https://www.github.com/DefinitelyTyped/DefinitelyTyped
i18next-browser-languagedetector-async
language detector used in browser environment for i18next
@byhuz/i18next-browser-languagedetector
language detector used in browser environment for i18next
language detector used in browser environment for i18next
npm install i18next-browser-languagedetector
Typescript
Module System
Node Version
NPM Version
99.3
Supply Chain
100
Quality
89.5
Maintenance
100
Vulnerability
100
License
JavaScript (94.91%)
TypeScript (5.09%)
Total Downloads
250,916,028
Last Day
386,151
Last Week
2,088,365
Last Month
8,868,557
Last Year
90,072,956
MIT License
901 Stars
264 Commits
92 Forks
8 Watchers
93 Branches
29 Contributors
Updated on Apr 30, 2025
Minified
Minified + Gzipped
Latest Version
8.1.0
Package Id
i18next-browser-languagedetector@8.1.0
Unpacked Size
85.82 kB
Size
13.48 kB
File Count
17
NPM Version
10.9.2
Node Version
22.15.0
Published on
Apr 30, 2025
Cumulative downloads
Total Downloads
Last Day
63%
386,151
Compared to previous day
Last Week
5.8%
2,088,365
Compared to previous week
Last Month
-0.4%
8,868,557
Compared to previous month
Last Year
47%
90,072,956
Compared to previous year
1
27
This is an i18next language detection plugin used to detect user language in the browser, with support for:
?lng=LANGUAGE
to URL)Source can be loaded via npm, bower or downloaded from this repo.
# npm package
$ npm install i18next-browser-languagedetector
# bower
$ bower install i18next-browser-languagedetector
window.i18nextBrowserLanguageDetector
Wiring up:
1import i18next from 'i18next'; 2import LanguageDetector from 'i18next-browser-languagedetector'; 3 4i18next.use(LanguageDetector).init({ 5 supportedLngs: ['de', 'en', 'fr'], 6 ...i18nextOptions 7});
As with all modules you can either pass the constructor function (class) to the i18next.use
or to a concrete instance.
supportedLngs
is optional, but allows i18next to pick the best match from the list of detected languages. If it's not set then language
will be set to the first detected language, regardless of whether your application has translations for that language or not.
The default options can be found here.
1{ 2 // order and from where user language should be detected 3 order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag', 'path', 'subdomain'], 4 5 // keys or params to lookup language from 6 lookupQuerystring: 'lng', 7 lookupCookie: 'i18next', 8 lookupLocalStorage: 'i18nextLng', 9 lookupSessionStorage: 'i18nextLng', 10 lookupFromPathIndex: 0, 11 lookupFromSubdomainIndex: 0, 12 13 // cache user language on 14 caches: ['localStorage', 'cookie'], 15 excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage) 16 17 // optional expiry and domain for set cookie 18 cookieMinutes: 10, 19 cookieDomain: 'myDomain', 20 21 // optional htmlTag with lang attribute, the default is: 22 htmlTag: document.documentElement, 23 24 // optional set cookie options, reference:[MDN Set-Cookie docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) 25 cookieOptions: { path: '/', sameSite: 'strict' }, 26 27 // optional conversion function used to modify the detected language code 28 convertDetectedLanguage: 'Iso15897', 29 convertDetectedLanguage: (lng) => lng.replace('-', '_') 30}
Options can be passed in:
preferred - by setting options.detection in i18next.init:
1import i18next from 'i18next'; 2import LanguageDetector from 'i18next-browser-languagedetector'; 3 4i18next.use(LanguageDetector).init({ 5 detection: options, 6});
on construction:
1import LanguageDetector from 'i18next-browser-languagedetector'; 2const languageDetector = new LanguageDetector(null, options);
via calling init:
1import LanguageDetector from 'i18next-browser-languagedetector'; 2const languageDetector = new LanguageDetector(); 3languageDetector.init(options);
1export default { 2 name: 'myDetectorsName', 3 4 lookup(options) { 5 // options -> are passed in options 6 return 'en'; 7 }, 8 9 cacheUserLanguage(lng, options) { 10 // options -> are passed in options 11 // lng -> current language, will be called after init and on changeLanguage 12 // store it 13 }, 14};
1import LanguageDetector from 'i18next-browser-languagedetector'; 2const languageDetector = new LanguageDetector(); 3languageDetector.addDetector(myDetector); 4 5i18next.use(languageDetector).init({ 6 detection: options, 7});
Don't forget: You have to add the name of your detector (myDetectorsName
in this case) to the order
array in your options
object. Without that, your detector won't be used. See the Detector Options section for more.
localization as a service - locize.com
Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!
With using locize you directly support the future of i18next and react-i18next.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
14 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
Found 8/23 approved changesets -- score normalized to 3
Reason
8 existing vulnerabilities detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More