@resonance-run/i18next-resonance-plugin
v0.4.0
Published
i18next plugin for Resonance
Downloads
112
Readme
@resonance-run/i18next-resonance-plugin
This package is used for getting Resonance working with i18next.
Installation
$ npm install @resonance-run/i18next-resonance-plugin
or
$ yarn add @resonance-run/i18next-resonance-plugin
Usage
import { createInstance } from 'i18next';
import { ResonancePostProcessor } from 'i18next-resonance-plugin';
export function handleRequst(request: Request) {
// ... clipped for brevity
const instance = createInstance();
await instance
.use(initReactI18next) // This example uses react-i18next
.use(FsBackend) // with a filesystem backend
// `use` the resonance plugin
.use(new ResonancePostProcessor({ request })) // Make sure to pass in the `request` object
.init({
...i18n, // spread the configuration
lng, // The locale we detected above
ns, // The namespaces the routes about to render wants to use
backend: { loadPath: resolve('./public/locales/{{lng}}/{{ns}}.json') },
postProcess: ['resonancePostProcessor'],
});
}