Skip to main content
Version: 7.x.x

Plugins

Tolgee​

TolgeeCore with added BrowserExtensionPlugin.

Usage:

const tolgee = Tolgee()
.use(...)
.updateDefaults(...)
.init(...)

LanguageStorage​

Plugin for storing current language in localStorage. It remembers the language if the user changed it.

tolgee.use(LanguageStorage());
info

Don't use language property with this plugin, as it will hard-override the languge. Instead use defaultLanguage.

LanguageDetector​

Plugin for language detection from the user's browser locale. It requires staticData or availableLanguages to be defined in Tolgee options, as it matches the locale with it.

tolgee.use(LanguageDetector());
info

Don't use language property with this plugin, as it will hard-override the languge. Instead use defaultLanguage.

BackendFetch​

Plugin for fetching translations JSON files.

tolgee.use(BackendFetch(options?: BackendOptions));

Pass BackendOptions to customize the behavior:

options.prefix​

Pass string to change URL prefix, use can use relative or absolute paths (Default: /i18n)

options.getPath​

Combines prefix, namespace and language and generates file path.

function ({ prefix, namespace, language }): string

Default returns {prefix}/{namespace}/{language}.json or {prefix}/{language}.json when namespace is empty.

options.getData​

Parses data from response, by default it returns r.json().

function (r: Response): Promise<any>;

options.headers​

Pass custom headers. Default: { Accept: 'application/json' }

DevTools​

It's a combination ObserverPlugin, ContextUi and DevBackend in one plugin, intended to enable in-context capabilities. It only applies plugins if there they are not already applied.

DevTools are automatically omitted in production builds (based on NODE_ENV variable).

If you need include in-context tools in your production build check InContextTools, which are completely equivalent to DevTools, only without auto-omitting logic.

DevBackend​

Plugin for communication with Tolgee platform uses apiUrl, apiKey (+ projectId) from Tolgee options.

tolgee.use(DevBackend());

ObserverPlugin​

Plugin which wraps translations and observes the DOM, so it's able to locate translations on the page. Read more in this article.

tolgee.use(ObserverPlugin());

You can influence the behavior of this plugin through observer options.

BrowserExtensionPlugin​

Plugin which connects Tolgee to the Tolgee Tools extension for Google Chrome or add-on for Mozilla Firefox. This plugin is automatically included in Tolgee, if you import it from @tolgee/web.

Since @tolgee/web 7.2.0 the plugin speaks the extension's protocol version 2. When the user signs in with their Tolgee account in the extension, the plugin routes the SDK's API requests through the extension instead of sending them with an API key. The page never receives the token. This needs projectId in the Tolgee options. See in-context on production.