Gathering detailed insights and metrics for i18next-browser-languagedetector-async
Gathering detailed insights and metrics for i18next-browser-languagedetector-async
npm install i18next-browser-languagedetector-async
Typescript
Module System
Node Version
NPM Version
74.2
Supply Chain
99
Quality
75.2
Maintenance
100
Vulnerability
100
License
JavaScript (93.75%)
TypeScript (6.25%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,465
Last Day
4
Last Week
14
Last Month
63
Last Year
404
MIT License
121 Commits
1 Watchers
92 Branches
1 Contributors
Updated on Aug 02, 2019
Minified
Minified + Gzipped
Latest Version
0.0.4
Package Id
i18next-browser-languagedetector-async@0.0.4
Unpacked Size
81.87 kB
Size
17.81 kB
File Count
40
NPM Version
6.9.0
Node Version
10.16.0
Cumulative downloads
Total Downloads
Last Day
100%
4
Compared to previous day
Last Week
16.7%
14
Compared to previous week
Last Month
65.8%
63
Compared to previous month
Last Year
86.2%
404
Compared to previous year
22
This is a i18next language detection plugin use 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 5 .use(LanguageDetector) 6 .init(i18nextOptions);
As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
1{ 2 // order and from where user language should be detected 3 order: ['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag', 'path', 'subdomain'], 4 5 // keys or params to lookup language from 6 lookupQuerystring: 'lng', 7 lookupCookie: 'i18next', 8 lookupLocalStorage: 'i18nextLng', 9 lookupFromPathIndex: 0, 10 lookupFromSubdomainIndex: 0, 11 12 // cache user language on 13 caches: ['localStorage', 'cookie'], 14 excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage) 15 16 // optional expire and domain for set cookie 17 cookieMinutes: 10, 18 cookieDomain: 'myDomain', 19 20 // optional htmlTag with lang attribute, the default is: 21 htmlTag: document.documentElement 22}
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 5 .use(LanguageDetector) 6 .init({ 7 detection: options 8 });
on construction:
1 import LanguageDetector from 'i18next-browser-languagedetector'; 2 const languageDetector = new LanguageDetector(null, options);
via calling init:
1 import LanguageDetector from 'i18next-browser-languagedetector'; 2 const languageDetector = new LanguageDetector(); 3 lngDetector.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 13 // store it 14 } 15};
1 import LanguageDetector from 'i18next-browser-languagedetector'; 2 const languageDetector = new LanguageDetector(); 3 languageDetector.addDetector(myDetector); 4 5 i18next 6 .use(languageDetector) 7 .init({ 8 detection: options 9 });
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-02-10
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