stream-chat-react
Version:
React components to create chat conversations or livestream style chat
680 lines • 31.4 kB
TypeScript
import Dayjs from 'dayjs';
import { TranslationBuilder } from './TranslationBuilder';
import type { i18n as I18n, TFunction } from 'i18next';
import type momentTimezone from 'moment-timezone';
import type { TranslationLanguages } from 'stream-chat';
import type { TranslationTopicConstructor } from './TranslationBuilder';
import type { UnknownType } from '../types/types';
import type { CustomFormatters, PredefinedFormatters, TDateTimeParser } from './types';
import { enTranslations } from './translations';
import 'dayjs/locale/de';
import 'dayjs/locale/es';
import 'dayjs/locale/fr';
import 'dayjs/locale/hi';
import 'dayjs/locale/it';
import 'dayjs/locale/ja';
import 'dayjs/locale/ko';
import 'dayjs/locale/nl';
import 'dayjs/locale/pt';
import 'dayjs/locale/ru';
import 'dayjs/locale/tr';
import 'dayjs/locale/en';
type CalendarLocaleConfig = {
lastDay: string;
lastWeek: string;
nextDay: string;
nextWeek: string;
sameDay: string;
sameElse: string;
};
type DateTimeParserModule = typeof Dayjs | typeof momentTimezone;
export type Streami18nOptions = {
DateTimeParser?: DateTimeParserModule;
dayjsLocaleConfigForLanguage?: Partial<ILocale> & {
calendar?: CalendarLocaleConfig;
};
debug?: boolean;
disableDateTimeTranslations?: boolean;
formatters?: Partial<PredefinedFormatters> & CustomFormatters;
language?: TranslationLanguages;
logger?: (message?: string) => void;
translationBuilderTopics?: Record<string, TranslationTopicConstructor>;
parseMissingKeyHandler?: (key: string, defaultValue?: string) => string;
timezone?: string;
translationsForLanguage?: Partial<typeof enTranslations>;
};
export declare class Streami18n {
i18nInstance: I18n;
translationBuilder: TranslationBuilder;
private translationBuilderTopics;
Dayjs: null;
setLanguageCallback: (t: TFunction) => void;
initialized: boolean;
t: TFunction;
tDateTimeParser: TDateTimeParser;
translations: {
[key: string]: {
[key: string]: typeof enTranslations | UnknownType;
};
};
/**
* dayjs.defineLanguage('nl') also changes the global locale. We don't want to do that
* when user calls registerTranslation() function. So instead we will store the locale configs
* given to registerTranslation() function in `dayjsLocales` object, and register the required locale
* with moment, when setLanguage is called.
* */
dayjsLocales: {
[key: string]: Partial<ILocale>;
};
/**
* Initialize properties used in constructor
*/
logger: (msg?: string) => void;
currentLanguage: TranslationLanguages;
DateTimeParser: DateTimeParserModule;
formatters: PredefinedFormatters & CustomFormatters;
isCustomDateTimeParser: boolean;
i18nextConfig: {
debug: boolean;
fallbackLng: false;
interpolation: {
escapeValue: boolean;
formatSeparator: string;
};
keySeparator: false;
lng: string;
nsSeparator: false;
parseMissingKeyHandler?: (key: string, defaultValue?: string) => string;
postProcess?: string[];
};
/**
* A valid TZ identifier string (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
*/
timezone?: string;
/**
* Constructor accepts following options:
* - language (String) default: 'en'
* Language code e.g., en, tr
*
* - translationsForLanguage (object)
* Translations object. Please check src/i18n/en.json for example.
*
* - disableDateTimeTranslations (boolean) default: false
* Disable translations for date-times
*
* - debug (boolean) default: false
* Enable debug mode in internal i18n class
*
* - logger (function) default: () => {}
* Logger function to log warnings/errors from this class
*
* - dayjsLocaleConfigForLanguage (object) default: 'enConfig'
* [Config object](https://momentjs.com/docs/#/i18n/changing-locale/) for internal moment object,
* corresponding to language (param)
*
* - DateTimeParser (function) Moment or Dayjs instance/function.
* Make sure to load all the required locales in this Moment or Dayjs instance that you will be provide to Streami18n
*
* @param {*} options
*/
constructor(options?: Streami18nOptions);
/**
* Initializes the i18next instance with configuration (which enables natural language as default keys)
*/
init(): Promise<{
t: TFunction<"translation", undefined>;
tDateTimeParser: TDateTimeParser;
}>;
localeExists: (language: TranslationLanguages) => boolean;
validateCurrentLanguage: () => void;
/** Returns an instance of i18next used within this class instance */
geti18Instance: () => I18n;
/** Returns list of available languages. */
getAvailableLanguages: () => string[];
/** Returns all the translation dictionary for all inbuilt-languages */
getTranslations: () => {
[key: string]: {
[key: string]: {
"{{ commaSeparatedUsers }} and {{ moreCount }} more": string;
"{{ commaSeparatedUsers }}, and {{ lastUser }}": string;
"{{ count }} files_one": string;
"{{ count }} files_other": string;
"{{ count }} people are typing_one": string;
"{{ count }} people are typing_many": string;
"{{ count }} people are typing_other": string;
"{{ count }} photos_one": string;
"{{ count }} photos_other": string;
"{{ count }} reactions_one": string;
"{{ count }} reactions_other": string;
"{{ count }} videos_one": string;
"{{ count }} videos_other": string;
"{{ firstUser }} and {{ secondUser }}": string;
"{{ imageCount }} more": string;
"{{ memberCount }} members": string;
"{{ typing }} are typing": string;
"{{ typing }} is typing": string;
"{{ user }} has been muted": string;
"{{ user }} has been unmuted": string;
"{{ user }} is typing...": string;
"{{ users }} and {{ user }} are typing...": string;
"{{ users }} and more are typing...": string;
"{{ watcherCount }} online": string;
"{{count}} new messages_one": string;
"{{count}} new messages_other": string;
"{{count}} unread_one": string;
"{{count}} unread_other": string;
"{{count}} votes_one": string;
"{{count}} votes_other": string;
"+{{ imageCount }}": string;
"+{{count}} more options_one": string;
"+{{count}} more options_other": string;
"\uD83C\uDFD9 Attachment...": string;
"\uD83D\uDCCA {{createdBy}} created: {{ pollName}}": string;
"\uD83D\uDCCA {{votedBy}} voted: {{pollOptionText}}": string;
"\uD83D\uDCCDShared location": string;
"Add a comment": string;
"Add a comment to your poll answer": string;
"Add an option": string;
"Add reaction": string;
"All results loaded": string;
"Allow access to camera": string;
"Allow access to microphone": string;
"Allow comments": string;
"Allow option suggestion": string;
"Allow others to add comments": string;
"Also send as a direct message": string;
"Also send in channel": string;
"Also sent in channel": string;
"An error has occurred during recording": string;
"An error has occurred during the recording processing": string;
Anonymous: string;
"Anonymous poll": string;
Archive: string;
"Are you sure you want to delete this message?": string;
"aria/Attachment": string;
"aria/Attachment Actions": string;
"aria/Audio position {{ elapsed }} of {{ duration }}": string;
"aria/Audio position {{ progress }} percent": string;
"aria/Block User": string;
"aria/Bookmark Message": string;
"aria/Cancel recording": string;
"aria/Cancel Reply": string;
"aria/Cancel upload": string;
"aria/Channel Actions": string;
"aria/Channel list": string;
"aria/Channel search results": string;
"aria/Chat view tabs": string;
"aria/Clear search": string;
"aria/Close callout dialog": string;
"aria/Close thread": string;
"aria/Collapse sidebar": string;
"aria/Command Suggestions": string;
"aria/Complete recording": string;
"aria/Copy Message Text": string;
"aria/Decrease value": string;
"aria/Delete Message": string;
"aria/Dismiss notification": string;
"aria/Download attachment": string;
"aria/Edit Message": string;
"aria/Emoji picker": string;
"aria/Emoji Suggestions": string;
"aria/Exit search": string;
"aria/Expand sidebar": string;
"aria/File input": string;
"aria/File upload": string;
"aria/Flag Message": string;
"aria/Image failed to load": string;
"aria/Image input": string;
"aria/Increase value": string;
"aria/Jump to latest message": string;
"aria/Jump to quoted message": string;
"aria/Load More Channels": string;
"aria/Mark Message Unread": string;
"aria/Mark messages as read": string;
"aria/Menu": string;
"aria/Message Actions": string;
"aria/Message from {{ user }},": string;
"aria/Message Options": string;
"aria/Message,": string;
"aria/Mute User": string;
"aria/Notifications": string;
"aria/Open Attachment Selector": string;
"aria/Open Channel Actions Menu": string;
"aria/Open Menu": string;
"aria/Open Message Actions Menu": string;
"aria/Open Reaction Selector": string;
"aria/Open Thread": string;
"aria/Pause": string;
"aria/Pause recording": string;
"aria/Percent complete": string;
"aria/Pin Message": string;
"aria/Play": string;
"aria/Quote Message": string;
"aria/Reaction list": string;
"aria/Remind Me Message": string;
"aria/Remind Me Options": string;
"aria/Remove attachment": string;
"aria/Remove location attachment": string;
"aria/Remove option": string;
"aria/Remove Reminder": string;
"aria/Remove Save For Later": string;
"aria/Resend Message": string;
"aria/Resume recording": string;
"aria/Retry upload": string;
"aria/Review bounced message": string;
"aria/Search results": string;
"aria/Search results header filter button for: {{ source }}": string;
"aria/Seek audio position": string;
"aria/Select Channel: {{ channelName }}": string;
"aria/Select Reaction: {{ reactionName }}": string;
"aria/Select User Channel: {{ name }}": string;
"aria/Send": string;
"aria/Show preview": string;
"aria/Start recording audio": string;
"aria/Stop AI Generation": string;
"aria/Suggestions": string;
"aria/Thread list": string;
"aria/Unblock User": string;
"aria/Unmute User": string;
"aria/Unpin Message": string;
"aria/User Suggestions": string;
"Ask a question": string;
Attach: string;
"Attach files": string;
Attachment: string;
"Attachment upload blocked due to {{reason}}": string;
"Attachment upload failed due to {{reason}}": string;
Back: string;
"ban-command-args": string;
"ban-command-description": string;
"Block User": string;
Cancel: string;
"Cannot seek in the recording": string;
"Channel archived": string;
"Channel Missing": string;
"Channel muted": string;
"Channel pinned": string;
"Channel unarchived": string;
"Channel unmuted": string;
"Channel unpinned": string;
Channels: string;
Chats: string;
"Choose between 2 to 10 options": string;
Close: string;
"Close dialog": string;
"Close emoji picker": string;
"Close prompt: {{ title }}": string;
"Command not available while editing": string;
"Command not available while replying": string;
Commands: string;
"Commands matching": string;
"Connection failure, reconnecting now...": string;
"Copy Message": string;
Create: string;
"Create a question, add options, and configure poll settings": string;
"Create poll": string;
"Current location": string;
Delete: string;
"Delete for me": string;
"Delete message": string;
Delivered: string;
"Direct message": string;
"Do you want to end this poll now? Nobody will be able to vote in this poll anymore.": string;
"Download All": string;
"Download Attachment": string;
"Download attachment {{ name }}": string;
"Drag your files here": string;
"Drag your files here to add to your post": string;
"Due {{ timeLeft }}": string;
"Due since {{ dueSince }}": string;
"duration/Message reminder": string;
"duration/Remind Me": string;
"duration/Share Location": string;
"Edit Message": string;
"Edit message request failed": string;
Edited: string;
"Emoji matching": string;
"Empty message...": string;
End: string;
"End poll": string;
"End this poll?": string;
"End vote": string;
"Enforce unique vote is enabled": string;
Error: string;
"Error adding flag": string;
"Error connecting to chat, refresh the page to try again.": string;
"Error deleting message": string;
"Error fetching reactions": string;
"Error marking message unread. Cannot mark unread messages older than the newest 100 channel messages.": string;
"Error muting a user ...": string;
"Error pinning message": string;
"Error removing message pin": string;
"Error reproducing the recording": string;
"Error starting recording": string;
"Error unmuting a user ...": string;
"Error uploading attachment": string;
"Error uploading file": string;
"Error uploading image": string;
"Error: {{ errorMessage }}": string;
"Exit command {{ command }}": string;
"Failed to block user": string;
"Failed to create the poll": string;
"Failed to create the poll due to {{reason}}": string;
"Failed to delete the message": string;
"Failed to end the poll": string;
"Failed to end the poll due to {{reason}}": string;
"Failed to jump to the first unread message": string;
"Failed to leave channel": string;
"Failed to load channels": string;
"Failed to load more channels": string;
"Failed to mark channel as read": string;
"Failed to play the recording": string;
"Failed to retrieve location": string;
"Failed to share location": string;
"Failed to update channel archive status": string;
"Failed to update channel mute status": string;
"Failed to update channel pinned status": string;
File: string;
"File is required for upload attachment": string;
"File is too large: {{ size }}, maximum upload size is {{ limit }}": string;
"File too large": string;
fileCount_one: string;
fileCount_other: string;
Flag: string;
"Generating...": string;
"giphy-command-args": string;
"giphy-command-description": string;
"Hide who voted": string;
Image: string;
imageCount_one: string;
imageCount_other: string;
"Instant commands": string;
"language/af": string;
"language/am": string;
"language/ar": string;
"language/az": string;
"language/bg": string;
"language/bn": string;
"language/bs": string;
"language/cs": string;
"language/da": string;
"language/de": string;
"language/el": string;
"language/en": string;
"language/es": string;
"language/es-MX": string;
"language/et": string;
"language/fa": string;
"language/fa-AF": string;
"language/fi": string;
"language/fr": string;
"language/fr-CA": string;
"language/ha": string;
"language/he": string;
"language/hi": string;
"language/hr": string;
"language/ht": string;
"language/hu": string;
"language/id": string;
"language/it": string;
"language/ja": string;
"language/ka": string;
"language/ko": string;
"language/lt": string;
"language/lv": string;
"language/ms": string;
"language/nl": string;
"language/no": string;
"language/pl": string;
"language/ps": string;
"language/pt": string;
"language/ro": string;
"language/ru": string;
"language/sk": string;
"language/sl": string;
"language/so": string;
"language/sq": string;
"language/sr": string;
"language/sv": string;
"language/sw": string;
"language/ta": string;
"language/th": string;
"language/tl": string;
"language/tr": string;
"language/uk": string;
"language/ur": string;
"language/vi": string;
"language/zh": string;
"language/zh-TW": string;
"Leave Channel": string;
"Left channel": string;
"Let others add options": string;
"Limit votes per person": string;
Link: string;
linkCount_one: string;
linkCount_other: string;
live: string;
"Live for {{duration}}": string;
"Live location": string;
"Live until {{ timestamp }}": string;
"Load more": string;
"Local upload attachment missing local id": string;
Location: string;
"Location sharing ended": string;
"Location: {{ coordinates }}": string;
"Mark as unread": string;
"Maximum number of votes (from 2 to 10)": string;
"Maximum votes per person": string;
Menu: string;
"Message deleted": string;
"Message failed to send": string;
"Message has been successfully flagged": string;
"Message marked as unread": string;
"Message pinned": string;
"Message unpinned": string;
"Message was blocked by moderation policies": string;
"Messages have been marked unread.": string;
"Missing permissions to upload the attachment": string;
"Multiple votes": string;
Mute: string;
"mute-command-args": string;
"mute-command-description": string;
"network error": string;
New: string;
"New message from {{user}}": string;
"New Messages!": string;
"Next image": string;
"No chats here yet\u2026": string;
"No conversations yet": string;
"No items exist": string;
"No results found": string;
"Nobody will be able to vote in this poll anymore.": string;
"Nothing yet...": string;
Offline: string;
Ok: string;
Online: string;
"Only numbers are allowed": string;
"Only visible to you": string;
"Open emoji picker": string;
"Open gallery at image {{ index }}": string;
"Open image in gallery": string;
"Open location in a map": string;
"Option already exists": string;
"Option is empty": string;
Options: string;
Original: string;
"People matching": string;
Photo: string;
Pin: string;
"Pinned by {{ name }}": string;
"Pinned by You": string;
"placeholder/PollComment": string;
"placeholder/PollOptionSuggestion": string;
"Play video": string;
"Playback speed {{ rate }}x": string;
Poll: string;
"Poll comments": string;
"Poll ended": string;
"Poll options": string;
"Poll results": string;
"Previous image": string;
Question: string;
"Question {{ optionOrderNumber}}": string;
"Question is required": string;
"Quote Reply": string;
"Reached the vote limit. Remove an existing vote first.": string;
"Recording format is not supported and cannot be reproduced": string;
"Remind me": string;
"Remind Me": string;
"Reminder set": string;
"Remove reminder": string;
"Remove save for later": string;
"Replied to a thread": string;
Reply: string;
"Reply to {{ authorName }}": string;
"Reply to a message to start a thread": string;
"Reply to Message": string;
replyCount_one: string;
replyCount_other: string;
Resend: string;
"Retry upload": string;
"Review all options available in this poll": string;
"Review comments submitted with poll answers": string;
"Review poll results and open an option to see detailed votes": string;
"Review this message and choose whether to delete it, edit it, or send it anyway": string;
"Review who voted for this option": string;
"Save for later": string;
"Saved for later": string;
Search: string;
"Search GIFs": string;
"search-results-header-filter-source-button-label--channels": string;
"search-results-header-filter-source-button-label--messages": string;
"search-results-header-filter-source-button-label--users": string;
"Searching for {{ searchSourceType }}...": string;
"Searching...": string;
searchResultsCount_one: string;
searchResultsCount_other: string;
"Select a thread to continue the conversation": string;
"Select more than one option": string;
"Select one": string;
"Select one or more": string;
"Select up to {{count}}_one": string;
"Select up to {{count}}_other": string;
"Select your current location and optionally enable live location sharing": string;
Send: string;
"Send a message": string;
"Send a message to start the conversation": string;
"Send Anyway": string;
"Send message request failed": string;
"Send poll": string;
"Sending...": string;
Sent: string;
Share: string;
"Share live location for": string;
"Share Location": string;
"Shared live location": string;
"Shared location": string;
Shuffle: string;
"size limit": string;
"Slow Mode ON": string;
"Slow mode, wait {{ seconds }}s...": string;
"Some of the files will not be accepted": string;
"Start typing to search": string;
"Stop sharing": string;
Submit: string;
"Suggest a new option to add to this poll": string;
"Suggest an option": string;
"Tap to remove": string;
"Tap to remove: {{ reactionName }}": string;
"Thinking...": string;
"this content could not be displayed": string;
"This field cannot be empty or contain only spaces": string;
"This message did not meet our content guidelines": string;
Thread: string;
"Thread has not been found": string;
"Thread reply": string;
"Thread Reply": string;
"ThreadListUnseenThreadsBanner/loading": string;
"ThreadListUnseenThreadsBanner/unreadThreads_one": string;
"ThreadListUnseenThreadsBanner/unreadThreads_other": string;
Threads: string;
"timestamp/ChannelPreviewTimestamp": string;
"timestamp/DateSeparator": string;
"timestamp/LiveLocation": string;
"timestamp/MessageTimestamp": string;
"timestamp/PollVote": string;
"timestamp/PollVoteTooltip": string;
"timestamp/relativeDaysAgo": string;
"timestamp/relativeToday": string;
"timestamp/relativeWeeksAgo": string;
"timestamp/relativeYesterday": string;
"timestamp/ReminderNotification": string;
"timestamp/SystemMessage": string;
"To start recording, allow the camera access in your browser": string;
"To start recording, allow the microphone access in your browser": string;
totalVoteCount_one: string;
totalVoteCount_other: string;
Translated: string;
"Translated from {{ language }}": string;
"translationBuilderTopic/notification": string;
"Type a number from 2 to 10": string;
Unarchive: string;
"unban-command-args": string;
"unban-command-description": string;
"Unblock User": string;
"unknown error": string;
Unmute: string;
"unmute-command-args": string;
"unmute-command-description": string;
Unpin: string;
"Unread messages": string;
"Unsupported attachment": string;
"unsupported file type": string;
Update: string;
"Update the comment attached to your poll answer": string;
"Update your comment": string;
"Upload blocked": string;
"Upload error": string;
"Upload failed": string;
"Upload type: \"{{ type }}\" is not allowed": string;
"User blocked": string;
"User unblocked": string;
"User uploaded content": string;
Video: string;
videoCount_one: string;
videoCount_other: string;
View: string;
"View {{count}} comments_one": string;
"View {{count}} comments_other": string;
"View all": string;
"View original": string;
"View results": string;
"View translation": string;
"Voice message": string;
"Voice message {{ duration }}": string;
"Voice message deleted": string;
voiceMessageCount_one: string;
voiceMessageCount_other: string;
"Vote ended": string;
Votes: string;
"Wait until all attachments have uploaded": string;
"Waiting for network\u2026": string;
You: string;
"You've reached the maximum number of files": string;
} | UnknownType;
};
};
/**
* Returns current version translator function.
*/
getTranslators(): Promise<{
t: TFunction<"translation", undefined>;
tDateTimeParser: TDateTimeParser;
}>;
registerTranslation(language: TranslationLanguages, translation: typeof enTranslations, customDayjsLocale?: Partial<ILocale>): void;
addOrUpdateLocale(key: TranslationLanguages, config: Partial<ILocale>): void;
setLanguage(language: TranslationLanguages): Promise<TFunction<"translation", undefined> | undefined>;
registerSetLanguageCallback(callback: (t: TFunction) => void): void;
}
export {};
//# sourceMappingURL=Streami18n.d.ts.map