Skip to main content
Version: 5.x.x

Installation (i18next)

To install Tolgee i18next integration library run:

npm install @tolgee/i18next

Then wrap your i18next instance withTolgee:

import i18n from 'i18next';
import { withTolgee, Tolgee, I18nextPlugin, DevTools } from '@tolgee/i18next';

const tolgee = Tolgee()
.use(DevTools())
.use(I18nextPlugin())
.init({
// for development
apiUrl: ...,
apiKey: ...,

// for production
staticData: {
'en:translation': ...,
'cs:translation': ...
}
});

withTolgee(i18n, tolgee)
.use(...)
.init(...)

Now you can use regular i18next translation features.

info

i18next namespaces are mapped to Tolgee namespaces and since i18next doesn't support empty namespace, you have to have your translations in some namespace in the Tolgee platform (i18next defaults to "translation").

Language detection/changes

Tolgee will follow i18next configuration, so you can use i18next language detectors or set the language manually.

To change language use i18next.changeLanguage function.

Preparing for production

In production mode, you should never use localization data from Tolgee REST API and never leak your API key. You should use data exported from the Tolgee platform or use Tolgee Content Delivery load localizations reliably.

Check Providing static data section.