Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@tolgee/i18next

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tolgee/i18next

Tolgee i18n integration.


Version published
Weekly downloads
5.1K
increased by5.24%
Maintainers
2
Weekly downloads
 
Created

Tolgee i18next integration

test workflow @tolgee/i18next version types typescript twitter github stars

Tolgee

Tolgee i18next integration. For more information about Tolgee Toolkit, visit our documentation website tolgee.io.

Installation

npm install i18next @tolgee/i18next

Usage

First, create a Tolgee instance and initialize it.

import i18next from 'i18next';
import { withTolgee } from "@tolgee/i18next";

withTolgee(i18n, { ... tolgee config ... })
  .init({ ... i18next config ... })

This will:

  • use add tolgeeBackend as backend plugin
  • use tolgeeProcessor for wrapping translations (with invivisible wrapperMode)
  • will call tolgeeApply on i18n instance to apply listeners and register tolgee (i18n.tolgee)
  • will wrap .init function with custom function, which will use tolgeeOptions to merge config with our custom config that is needed for in-context to work

We also recommend using ICU message format, which is supported by Tolgee platform.

npm install i18next-icu
import ICU from 'i18next-icu';

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

Language changing

Tolgee will automatically switch language accordingly to i18next. So to get current language do:

const lang = i18n.lang;

To set language:

i18n.changeLanguage(lang);

To learn more, check Tolgee docs.

FAQs

Package last updated on 28 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts