Gathering detailed insights and metrics for i18next-chained-backend
Gathering detailed insights and metrics for i18next-chained-backend
Gathering detailed insights and metrics for i18next-chained-backend
Gathering detailed insights and metrics for i18next-chained-backend
i18next-fs-backend
i18next-fs-backend is a backend layer for i18next using in Node.js and for Deno to load translations from the filesystem.
i18next-localstorage-backend
caching layer backend for i18next using browsers localStorage
i18next-http-backend
i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
i18next
i18next internationalization framework
An i18next backend to chain multiple backends (add fallbacks, caches, ...)
npm install i18next-chained-backend
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
69 Stars
79 Commits
10 Forks
3 Watching
1 Branches
7 Contributors
Updated on 17 Oct 2024
JavaScript (97.67%)
TypeScript (2.33%)
Cumulative downloads
Total Downloads
Last day
-5%
33,135
Compared to previous day
Last week
-0.4%
168,717
Compared to previous week
Last month
12.9%
697,262
Compared to previous month
Last year
17.9%
7,279,834
Compared to previous year
1
This is a i18next backend to chain multiple other backends and caches. So you can define an additional caching backend or fallback backends.
Usage examples for caching configurations can be found here and for fallback backends can be found here.
For each backend read call (so for each language and namespace combination), it will try to read from from all backends in order until a backend returns some resources. So if it does not find the resource (language + namespace) in the first backend, it goes to the next, etc.
Source can be loaded via npm or downloaded from this repo.
# npm package
$ npm install i18next-chained-backend
Wiring up:
1import i18next from 'i18next'; 2import Backend from 'i18next-chained-backend'; 3 4i18next 5 .use(Backend) 6 .init(i18nextOptions);
window.i18nextChainedBackend
1{ 2 // array of existing i18next backends from https://www.i18next.com/overview/plugins-and-utils#backends 3 backends: [], 4 5 // array of options in order of backends above 6 backendOptions: [] 7}
Options can be passed in:
preferred - by setting options.backend in i18next.init:
1import i18next from 'i18next'; 2import Backend from 'i18next-chained-backend'; 3 4i18next 5 .use(Backend) 6 .init({ 7 backend: options 8 });
on construction:
1 import Backend from 'i18next-chained-backend'; 2 const Backend = new Backend(null, options);
via calling init:
1 import Backend from 'i18next-chained-backend'; 2 const Backend = new Backend(); 3 Backend.init(null, options);
1import i18next from 'i18next'; 2import Backend from 'i18next-chained-backend'; 3import LocalStorageBackend from 'i18next-localstorage-backend'; // load from local storage 4import HttpApi from 'i18next-http-backend'; // have a own http fallback 5 6i18next 7 .use(Backend) 8 .init({ 9 backend: { 10 backends: [ 11 LocalStorageBackend, // primary 12 HttpApi // fallback 13 ], 14 backendOptions: [{ 15 projectId: 'myLocizeProjectId' 16 }, { 17 loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback 18 }], 19 // cacheHitMode: 'none' // (default) 20 // cacheHitMode: 'refresh' // tries to refresh the cache by loading from the next backend and updates the cache 21 // cacheHitMode: 'refreshAndUpdateStore' // tries to refresh the cache by loading from the next backend, updates the cache and also update the i18next resource store 22 // reloadInterval: 60 * 60 * 1000 // can be used to reload resources in a specific interval (useful in server environments) 23 // refreshExpirationTime: 7 * 24 * 60 * 60 * 1000 // In case of caching with 'refresh' or 'refreshAndUpdateStore', it will only fetch from the next backend if the cached namespace is expired. Only supported if the backend returns the saved timestamp, like i18next-fs-backend, i18next-localstorage-backend 24 } 25 });
1import i18next from 'i18next'; 2import Backend from 'i18next-chained-backend'; 3import Locize from 'i18next-locize-backend'; // load from service 4import HttpApi from 'i18next-http-backend'; // have a own http fallback 5 6i18next 7 .use(Backend) 8 .init({ 9 backend: { 10 backends: [ 11 Locize, // primary 12 HttpApi // fallback 13 ], 14 backendOptions: [{ 15 projectId: 'myLocizeProjectId' 16 }, { 17 loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback 18 }] 19 } 20 });
More locize examples can be found here:
To properly type the backend options, you can import the ChainedBackendOptions
interface and use it as a generic type parameter to the i18next's init
method, e.g.:
1import i18n from 'i18next' 2import ChainedBackend, { ChainedBackendOptions } from 'i18next-chained-backend' 3 4i18n 5 .use(ChainedBackend) 6 .init<ChainedBackendOptions>({ 7 backend: { 8 backends: [ 9 Locize, // primary 10 HttpApi // fallback 11 ], 12 backendOptions: [{ 13 projectId: 'myLocizeProjectId' 14 }, { 15 loadPath: '/locales/{{lng}}/{{ns}}.json' // http api load path for my own fallback 16 }] 17 } 18 19 // other i18next options 20 })
We suggest not to use mutliple backends in combination with saveMissing or updateMissing, because it may happen, that the trigger for this is based on stale data.
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
9 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/27 approved changesets -- score normalized to 0
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-25
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