diff --git a/README.md b/README.md index f47785f..fb90198 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,41 @@ yarn add i18next-async-backend import i18next from 'i18next' import AsyncBackend from 'i18next-async-backend' +const resources = { + es: () => import('./locales/es/translation.json'), +} + i18next.use(AsyncBackend).init({ - backend: { - resources: { - en: {}, - }, - }, + backend: { resources }, }) ``` +## Recipes + +### Single namespace + +```js +const resources = { + en: () => import('./locales/en/translation.json'), + es: () => import('./locales/es/translation.json'), +} +``` + +### Multiple namespaces + +```js +const resources = { + en: { + common: () => import('./locales/en/common.json'), + glossary: () => import('./locales/en/glossary.json'), + }, + es: { + common: () => import('./locales/es/common.json'), + glossary: () => import('./locales/es/glossary.json'), + }, +} +``` + ## Releasing This extension uses [semantic-release](https://github.com/semantic-release/semantic-release) to automatically increment the release based on the commit message. Checkout [their docs](https://github.com/semantic-release/semantic-release#how-does-it-work) for more details.