Gathering detailed insights and metrics for @prebsch-exo/i18next-browser-languagedetector
NPM registry records approximately 1.5 to 2 billion package downloads per day.
Gathering detailed insights and metrics for @prebsch-exo/i18next-browser-languagedetector
NPM registry records approximately 1.5 to 2 billion package downloads per day.
npm install @prebsch-exo/i18next-browser-languagedetector
74.4
Supply Chain
98.5
Quality
75
Maintenance
100
Vulnerability
100
License
871 Stars
246 Commits
89 Forks
9 Watching
92 Branches
27 Contributors
Updated on 20 Nov 2024
JavaScript (94.47%)
TypeScript (5.53%)
Cumulative downloads
Total Downloads
Last day
0%
20
Compared to previous day
Last week
-12.6%
188
Compared to previous week
Last month
-27.4%
846
Compared to previous month
Last year
144.4%
27,169
Compared to previous year
1
26
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
license file detected
Details
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 6/23 approved changesets -- score normalized to 2
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 2024-11-18
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