UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

36 lines (35 loc) 1.67 kB
import type { i18n, TFunction } from 'i18next'; type TopicName = string; type TranslatorName = string; export type Translator<O extends Record<string, unknown> = Record<string, unknown>> = (params: { key: string; value: string; t: TFunction; options: O; }) => string | null; export type TranslationTopicOptions<O extends Record<string, unknown> = Record<string, unknown>> = { i18next: i18n; translators?: Record<string, Translator<O>>; }; export declare abstract class TranslationTopic<O extends Record<string, unknown> = Record<string, unknown>> { protected options: TranslationTopicOptions<O>; protected translators: Map<string, Translator<O>>; protected i18next: i18n; constructor(options: TranslationTopicOptions<O>); abstract translate(value: string, key: string, options: O): string; setTranslator: (name: string, translator: Translator<O>) => void; removeTranslator: (name: string) => void; } export type TranslationTopicConstructor = new (options: TranslationTopicOptions) => TranslationTopic; export declare class TranslationBuilder { private i18next; private topics; private translatorRegistrationsBuffer; constructor(i18next: i18n); registerTopic: (name: TopicName, Topic: TranslationTopicConstructor) => TranslationTopic<Record<string, unknown>>; disableTopic: (topicName: TopicName) => void; getTopic: (topicName: TopicName) => TranslationTopic<Record<string, unknown>> | undefined; registerTranslators(topicName: TopicName, translators: Record<TranslatorName, Translator>): void; removeTranslators(topicName: TopicName, translators: TranslatorName[]): void; } export {};