11import React , { useContext } from 'react' ;
22import { View , type ViewStyle } from 'react-native' ;
33import Touchable from 'react-native-platform-touchable' ;
4+ import { A11y } from 'react-native-a11y-order' ;
45
56import MessageContext from './Context' ;
67import User from './User' ;
@@ -25,6 +26,7 @@ import { getInfoMessage } from './utils';
2526import MessageTime from './Time' ;
2627import { useResponsiveLayout } from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout' ;
2728import Quote from './Components/Attachments/Quote' ;
29+ import translationLanguages from '../../lib/constants/translationLanguages' ;
2830
2931const MessageInner = React . memo ( ( props : IMessageInner ) => {
3032 const { isLargeFontScale } = useResponsiveLayout ( ) ;
@@ -145,7 +147,11 @@ const Message = React.memo((props: IMessageTouchable & IMessage) => {
145147 ! props . unread && props . unread !== null ? i18n . t ( 'Message_was_read' ) : i18n . t ( 'Message_was_not_read' ) ;
146148 const readReceipt = props . isReadReceiptEnabled && ! props . isInfo ? readOrUnreadLabel : '' ;
147149 const encryptedMessageLabel = props . isEncrypted ? i18n . t ( 'Encrypted_message' ) : '' ;
148- return `${ user } ${ hour } ${ label } . ${ encryptedMessageLabel } ${ readReceipt } ` ;
150+ const translatedLanguage = translationLanguages [ props ?. autoTranslateLanguage || 'en' ] ;
151+ const translated = props . isTranslated ? i18n . t ( 'Message_translated_into_idiom' , { idiom : translatedLanguage } ) : '' ;
152+ return props . isTranslated
153+ ? `${ user } ${ hour } ${ translated } `
154+ : `${ user } ${ hour } ${ translated } ${ label } . ${ encryptedMessageLabel } ${ readReceipt } ` ;
149155 } ;
150156
151157 if ( props . isThreadReply || props . isThreadSequential || props . isInfo || props . isIgnored ) {
@@ -157,39 +163,51 @@ const Message = React.memo((props: IMessageTouchable & IMessage) => {
157163 { thread }
158164 < View accessible accessibilityLabel = { accessibilityLabel ( ) } style = { [ styles . flex , infoStyle ] } >
159165 < MessageAvatar small { ...props } />
160- < View style = { styles . messageContent } >
161- < Content { ...props } />
162- { props . isInfo && props . type === 'message_pinned' ? (
163- < View pointerEvents = 'none' >
164- < Attachments { ...props } />
165- </ View >
166- ) : null }
167- </ View >
166+ < A11y . Index
167+ accessible = { props . isTranslated }
168+ accessibilityLabel = { props ?. msg || '' }
169+ accessibilityLanguage = { props . autoTranslateLanguage }
170+ index = { 2 } >
171+ < View style = { styles . messageContent } >
172+ < Content { ...props } />
173+ { props . isInfo && props . type === 'message_pinned' ? (
174+ < View pointerEvents = 'none' >
175+ < Attachments { ...props } />
176+ </ View >
177+ ) : null }
178+ </ View >
179+ </ A11y . Index >
168180 </ View >
169181 </ View >
170182 ) ;
171183 }
172184
173185 return (
174186 < View testID = { `message-${ props . id } ` } accessible accessibilityLabel = { accessibilityLabel ( ) } style = { styles . container } >
175- < View style = { styles . flex } >
176- < MessageAvatar { ...props } />
177- < View style = { styles . messageContent } >
178- < MessageInner { ...props } />
187+ < A11y . Index
188+ accessible = { props . isTranslated }
189+ accessibilityLabel = { props ?. msg || '' }
190+ accessibilityLanguage = { props . autoTranslateLanguage }
191+ index = { 2 } >
192+ < View accessible style = { styles . flex } >
193+ < MessageAvatar { ...props } />
194+ < View style = { styles . messageContent } >
195+ < MessageInner { ...props } />
196+ </ View >
197+ { ! props . isHeader ? (
198+ < RightIcons
199+ type = { props . type }
200+ msg = { props . msg }
201+ isEdited = { props . isEdited }
202+ hasError = { props . hasError }
203+ isReadReceiptEnabled = { props . isReadReceiptEnabled }
204+ unread = { props . unread }
205+ pinned = { props . pinned }
206+ isTranslated = { props . isTranslated }
207+ />
208+ ) : null }
179209 </ View >
180- { ! props . isHeader ? (
181- < RightIcons
182- type = { props . type }
183- msg = { props . msg }
184- isEdited = { props . isEdited }
185- hasError = { props . hasError }
186- isReadReceiptEnabled = { props . isReadReceiptEnabled }
187- unread = { props . unread }
188- pinned = { props . pinned }
189- isTranslated = { props . isTranslated }
190- />
191- ) : null }
192- </ View >
210+ </ A11y . Index >
193211 </ View >
194212 ) ;
195213} ) ;
@@ -209,20 +227,26 @@ const MessageTouchable = React.memo((props: IMessageTouchable & IMessage) => {
209227
210228 if ( props . hasError || props . isInfo ) {
211229 return (
212- < View >
230+ < A11y . Order >
213231 < Message { ...props } />
214- </ View >
232+ </ A11y . Order >
215233 ) ;
216234 }
217235
218236 return (
219- < Touchable
220- onLongPress = { onLongPress }
221- onPress = { onPress }
222- disabled = { ( props . isInfo && ! props . isThreadReply ) || props . archived || props . isTemp || props . type === 'jitsi_call_started' }
223- style = { { backgroundColor } } >
224- < Message { ...props } />
225- </ Touchable >
237+ < A11y . Order >
238+ < A11y . Index index = { 1 } >
239+ < Touchable
240+ onLongPress = { onLongPress }
241+ onPress = { onPress }
242+ disabled = {
243+ ( props . isInfo && ! props . isThreadReply ) || props . archived || props . isTemp || props . type === 'jitsi_call_started'
244+ }
245+ style = { { backgroundColor } } >
246+ < Message { ...props } />
247+ </ Touchable >
248+ </ A11y . Index >
249+ </ A11y . Order >
226250 ) ;
227251} ) ;
228252
0 commit comments