Skip to main content
Version: v11 (legacy)

TranslationContext

The component library uses the i18next dependency to create a Streami18n class constructor that handles language translation. The TranslationContext stores the resulting values and allows children of the Chat component to auto translate library text based on the connected user's set languages. You can access the context values by calling the useTranslationContext custom hook.

Basic Usage

Pull values from context with our custom hook:

const { t } = useTranslationContext();

<div className='message'>{t('This message will be translated.')}</div>;

Values

t

Function that translates text into the connected user's set language.

Type
function

tDateTimeParser

Function that parses date times.

TypeDefault
functionDay.js

userLanguage

Value to set the connected user's language (ex: 'en', 'fr', 'ru', etc), which auto translates text fields in the library.

TypeDefault
string'en'

Did you find this page helpful?