Skip to content

Commit

Permalink
docs: Update README with addResourceBundle info (#1425)
Browse files Browse the repository at this point in the history
* Update README with addResourceBundle info 

To avoid anymore issues being filed with a problem that has already been answered. I'm adding the answer provided in #1424

* Apply suggestions from code review

Co-authored-by: Isaac Hinman <[email protected]>

Co-authored-by: Isaac Hinman <[email protected]>
  • Loading branch information
JosephChotard and isaachinman authored Sep 27, 2021
1 parent 2943ee2 commit d8ad005
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@ This option will reload your translations whenever `serverSideTranslations` is c

All other [i18next options](https://www.i18next.com/overview/configuration-options) can be passed in as well.

#### Loading Namespaces Dynamically Client Side

In some use cases, you might want to load a translation file dynamically without having to use `serverSideTranslations`. This can be especially useful for lazy-loaded components that you don't want slowing down pages.

This can easily be done by using [addResourceBundle](https://www.i18next.com/how-to/add-or-load-translations#add-after-init):

```tsx
import { i18n } from 'next-i18next'

const Component = () => {
const { locale } = useRouter()

useEffect(() => {
i18n.addResourceBundle(locale, '<namespace name>')
}, [])
}
```

## Migration to v8

To migrate from previous versions to the version 8, check out the [v8-migration guide](https://github.com/isaachinman/next-i18next/tree/master/docs/v8-migration.md)
Expand Down

1 comment on commit d8ad005

@vercel
Copy link

@vercel vercel bot commented on d8ad005 Sep 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.