Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/widen/i18next-async-backend
i18next backend which loads resources via promises. Useful when loading resources via dynamic imports.
https://github.com/widen/i18next-async-backend
dynamic-import frontend i18next i18next-backend i18next-plugin
Last synced: about 5 hours ago
JSON representation
i18next backend which loads resources via promises. Useful when loading resources via dynamic imports.
- Host: GitHub
- URL: https://github.com/widen/i18next-async-backend
- Owner: Widen
- License: isc
- Created: 2021-03-25T23:01:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-28T14:37:01.000Z (over 2 years ago)
- Last Synced: 2024-11-09T15:47:45.439Z (10 days ago)
- Topics: dynamic-import, frontend, i18next, i18next-backend, i18next-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/i18next-async-backend
- Size: 2.82 MB
- Stars: 3
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# i18next-async-backend
[![Build](https://github.com/Widen/i18next-async-backend/actions/workflows/build.yml/badge.svg)](https://github.com/Widen/i18next-async-backend/actions/workflows/build.yml)
[![npm](https://img.shields.io/npm/v/i18next-async-backend)](https://www.npmjs.com/package/i18next-async-backend)
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-blue)](https://github.com/atlassian/changesets)[i18next](https://www.i18next.com) backend which loads resources via promises.
Useful when loading resources via dynamic imports.## Installation
### npm
```sh
npm install i18next-async-backend
```### Yarn
```
yarn add i18next-async-backend
```## Usage
```js
import i18next from 'i18next'
import AsyncBackend from 'i18next-async-backend'const resources = {
es: () => import('./locales/es/translation.json'),
}i18next.use(AsyncBackend).init({
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'),
},
}
```