@@ -4,7 +4,8 @@ import * as React from 'react';
44import { Text , GestureResponderEvent } from 'react-native' ;
55import * as Client from 'stream-chat' ;
66import * as SeamlessImmutable from 'seamless-immutable' ;
7-
7+ import * as i18next from 'i18next' ;
8+ import * as moment from 'moment' ;
89//================================================================================================
910//================================================================================================
1011//
@@ -27,6 +28,13 @@ export interface ChatContextValue {
2728 connectionRecovering ?: boolean ;
2829}
2930
31+ declare function withTranslationContext < T > (
32+ OriginalComponent : React . ElementType < T > ,
33+ ) : React . ElementType < T > ;
34+ export interface TranslationContext
35+ extends React . Context < TranslationContextValue > { }
36+ export interface TranslationContextValue extends Streami18nTranslators { }
37+
3038declare function withSuggestionsContext < T > (
3139 OriginalComponent : React . ElementType < T > ,
3240) : React . ElementType < T > ;
@@ -141,7 +149,9 @@ export interface ChatProps {
141149 style ?: object ;
142150}
143151
144- export interface ChannelProps extends ChatContextValue {
152+ export interface ChannelProps
153+ extends ChatContextValue ,
154+ TranslationContextValue {
145155 /** The loading indicator to use */
146156 LoadingIndicator ?: React . ElementType ;
147157 LoadingErrorIndicator ?: React . ElementType < LoadingErrorIndicatorProps > ;
@@ -202,12 +212,12 @@ export interface EmptyStateIndicatorProps {
202212export interface LoadingIndicatorProps {
203213 listType ?: listType ;
204214}
205- export interface DateSeparatorProps {
215+ export interface DateSeparatorProps extends TranslationContextValue {
206216 message : Client . MessageResponse ;
207217 formatDate ( date : string ) : string ;
208218}
209219
210- export interface EventIndicatorProps {
220+ export interface EventIndicatorProps extends TranslationContextValue {
211221 event :
212222 | Client . Event < Client . MemberAddedEvent >
213223 | Client . Event < Client . MemberRemovedEvent > ;
@@ -234,7 +244,8 @@ export interface FileUploadResponse {
234244export interface MessageInputProps
235245 extends KeyboardContextValue ,
236246 ChannelContextValue ,
237- SuggestionsContextValue {
247+ SuggestionsContextValue ,
248+ TranslationContextValue {
238249 /** The parent message object when replying on a thread */
239250 parent ?: Client . Message | null ;
240251
@@ -345,7 +356,9 @@ export interface ChannelListUIComponentProps
345356 loadNextPage ( ) : void ;
346357}
347358
348- export interface ChannelPreviewProps extends ChannelListUIComponentProps {
359+ export interface ChannelPreviewProps
360+ extends ChannelListUIComponentProps ,
361+ TranslationContextValue {
349362 Preview : React . ElementType < ChannelPreviewUIComponentProps > ;
350363 key : string ;
351364}
@@ -368,7 +381,9 @@ export interface ChannelPreviewUIComponentProps
368381 latestMessageLength : number ;
369382}
370383
371- export interface MessageListProps extends ChannelContextValue {
384+ export interface MessageListProps
385+ extends ChannelContextValue ,
386+ TranslationContextValue {
372387 /** Turn off grouping of messages by user */
373388 messageActions : Array < MessageAction > ;
374389 noGroupByUser ?: boolean ;
@@ -510,7 +525,8 @@ export interface MessageUIComponentProps
510525 formatDate ( date : string ) : string ;
511526}
512527
513- export interface MessageRepliesUIComponentProps {
528+ export interface MessageRepliesUIComponentProps
529+ extends TranslationContextValue {
514530 /** Current [message object](https://getstream.io/chat/docs/#message_format) */
515531 message : Client . MessageResponse ;
516532 /** Boolean if current message is part of thread */
@@ -553,7 +569,8 @@ export interface MessageAvatarUIComponentProps {
553569}
554570
555571export interface MessageContentUIComponentProps
556- extends MessageUIComponentProps {
572+ extends MessageUIComponentProps ,
573+ TranslationContextValue {
557574 alignment : string ;
558575}
559576
@@ -583,7 +600,9 @@ export interface MessageTextProps {
583600 message : Client . MessageResponse ;
584601}
585602
586- export interface ThreadProps extends ChannelContextValue {
603+ export interface ThreadProps
604+ extends ChannelContextValue ,
605+ TranslationContextValue {
587606 /** the thread (the parent message object) */
588607 thread : SeamlessImmutable . Immutable < Client . MessageResponse > ;
589608 /** The list of messages to render, state is handled by the parent channel component */
@@ -595,7 +614,7 @@ export interface ThreadProps extends ChannelContextValue {
595614 additionalMessageInputProps ?: object ;
596615}
597616
598- export interface TypingIndicatorProps {
617+ export interface TypingIndicatorProps extends TranslationContextValue {
599618 typing : [ ] ;
600619 client : Client . StreamChat ;
601620}
@@ -605,7 +624,7 @@ export interface FileIconUIComponentProps {
605624 mimeType ?: string ;
606625}
607626
608- export interface AutoCompleteInputProps {
627+ export interface AutoCompleteInputProps extends TranslationContextValue {
609628 value : string ;
610629 openSuggestions ?( title : string , component : React . ElementType < any > ) : void ;
611630 closeSuggestions ?( ) : void ;
@@ -647,7 +666,7 @@ export interface FileUploadPreviewProps {
647666 retryUpload ?( id : string ) : Promise < any > ;
648667 AttachmentFileIcon : React . ElementType < any > ;
649668}
650- export interface GalleryProps {
669+ export interface GalleryProps extends TranslationContextValue {
651670 images : Client . Attachment [ ] ;
652671 onLongPress : ( event : GestureResponderEvent ) => void ;
653672 alignment : 'right' | 'left' ;
@@ -685,27 +704,27 @@ export interface EventIndicatorProps {
685704 | null ;
686705}
687706
688- export interface LoadingErrorIndicatorProps {
707+ export interface LoadingErrorIndicatorProps extends TranslationContextValue {
689708 listType ?: listType ;
690709}
691- export interface LoadingIndicatorProps {
710+ export interface LoadingIndicatorProps extends TranslationContextValue {
692711 listType ?: listType ;
693712 loadingText ?: string ;
694713}
695- export interface MentionsItemProps {
714+ export interface MentionsItemProps extends TranslationContextValue {
696715 item : {
697716 name ?: string ;
698717 image ?: string ;
699718 id : string ;
700719 } ;
701720}
702721
703- export interface MessageNotificationProps {
722+ export interface MessageNotificationProps extends TranslationContextValue {
704723 showNotification : boolean ;
705724 onPress ?( event : GestureResponderEvent ) : void ;
706725}
707726
708- export interface MessageSystemProps {
727+ export interface MessageSystemProps extends TranslationContextValue {
709728 message : Client . MessageResponse ;
710729}
711730
@@ -927,3 +946,39 @@ export function registerNativeHandlers(handlers: {
927946 pickImage ( ) : Promise < any > ;
928947 pickDocument ( ) : Promise < any > ;
929948} ) : void ;
949+
950+ export interface Streami18nOptions {
951+ language : string ;
952+ disableDateTimeTranslations : boolean ;
953+ debug : boolean ;
954+ logger ( msg : string ) : any ;
955+ momentLocaleConfigForLanguage : object ;
956+ }
957+
958+ export interface Streami18nTranslators {
959+ t ?: i18next . TFunction ;
960+ moment ?( ) : moment . Moment ;
961+ }
962+
963+ export class Streami18n {
964+ constructor ( options ?: Streami18nOptions ) ;
965+
966+ init ( ) : Promise < Streami18nTranslators > ;
967+ momentLocaleExists ( language : String ) : boolean ;
968+ validateCurrentLanguage ( ) : void ;
969+ geti18Instance ( ) : i18next . i18n ;
970+ getAvailableLanguages ( ) : Array < String > ;
971+ getTranslations ( ) : Array < Object > ;
972+ getTranslators ( ) : Promise < Streami18nTranslators > ;
973+ registerTranslation (
974+ key : String ,
975+ translation : Object ,
976+ customMomentLocale : moment . LocaleSpecification ,
977+ ) : void ;
978+ addOrUpdateMomentLocaleConfig (
979+ key : String ,
980+ customMomentLocale : moment . LocaleSpecification ,
981+ ) : void ;
982+ setLanguage ( language : String ) : Promise < void > ;
983+ registerSetLanguageCallback ( callback : ( t : i18next . TFunction ) => void ) : void ;
984+ }
0 commit comments