diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index 020dbe5eef..a972385281 100644 --- a/MatrixSDK/Data/MXRoom.m +++ b/MatrixSDK/Data/MXRoom.m @@ -2194,15 +2194,9 @@ - (void)getReplyContentBodiesWithEventToReply:(MXEvent*)eventToReply } if (eventToReply.eventType == MXEventTypePollEnd) { - MXEvent* pollStartEvent = [mxSession.store eventWithEventId:eventToReply.relatesTo.eventId inRoom:self.roomId]; - - if (pollStartEvent) { - NSString *question = [MXEventContentPollStart modelFromJSON:pollStartEvent.content].question; - senderMessageBody = question; - } else { - // we need a fallback to avoid crashes since the m.poll.start event may be missing. - senderMessageBody = eventToReply.relatesTo.eventId; - } + // The "Ended poll" text is not meant to be localized from the sender side. + // This is why here we use a "default localizer" providing the english version of it. + senderMessageBody = MXSendReplyEventDefaultStringLocalizer.new.replyToEndedPoll; } else if (eventToReply.eventType == MXEventTypeBeaconInfo) { @@ -2278,8 +2272,7 @@ - (void)getReplyContentBodiesWithEventToReply:(MXEvent*)eventToReply *replyContentFormattedBody = [self replyMessageFormattedBodyFromEventToReply:eventToReply senderMessageFormattedBody:senderMessageFormattedBody isSenderMessageAnEmote:isSenderMessageAnEmote - replyFormattedMessage:finalFormattedTextMessage - stringLocalizer:stringLocalizer]; + replyFormattedMessage:finalFormattedTextMessage]; } } @@ -2369,7 +2362,6 @@ - (NSString*)replyMessageBodyFromSender:(NSString*)sender @param senderMessageFormattedBody The message body of the sender. @param isSenderMessageAnEmote Indicate if the sender message is an emote (/me). @param replyFormattedMessage The response for the sender message. HTML formatted string if any otherwise non formatted string as reply formatted body is mandatory. - @param stringLocalizer string localizations used when building formatted body. @return reply message body. */ @@ -2377,7 +2369,6 @@ - (NSString*)replyMessageFormattedBodyFromEventToReply:(MXEvent*)eventToReply senderMessageFormattedBody:(NSString*)senderMessageFormattedBody isSenderMessageAnEmote:(BOOL)isSenderMessageAnEmote replyFormattedMessage:(NSString*)replyFormattedMessage - stringLocalizer:(id)stringLocalizer { NSString *eventId = eventToReply.eventId; NSString *roomId = eventToReply.roomId; @@ -2423,7 +2414,9 @@ - (NSString*)replyMessageFormattedBodyFromEventToReply:(MXEvent*)eventToReply [replyMessageFormattedBody appendString:@"
"]; // Add event link - [replyMessageFormattedBody appendFormat:@"%@ ", eventPermalink, stringLocalizer.messageToReplyToPrefix]; + // The "In reply to" string is not meant to be localized from the sender side. + // This is how here we use the default string localizer to send the english version of it. + [replyMessageFormattedBody appendFormat:@"%@ ", eventPermalink, MXSendReplyEventDefaultStringLocalizer.new.messageToReplyToPrefix]; if (isSenderMessageAnEmote) { diff --git a/MatrixSDK/Data/MXSendReplyEventDefaultStringLocalizer.m b/MatrixSDK/Data/MXSendReplyEventDefaultStringLocalizer.m index 572103bd91..25a39022b5 100644 --- a/MatrixSDK/Data/MXSendReplyEventDefaultStringLocalizer.m +++ b/MatrixSDK/Data/MXSendReplyEventDefaultStringLocalizer.m @@ -26,6 +26,7 @@ @interface MXSendReplyEventDefaultStringLocalizer () @property (nonatomic, strong) NSString *senderSentTheirLocation; @property (nonatomic, strong) NSString *senderSentTheirLiveLocation; @property (nonatomic, strong) NSString *messageToReplyToPrefix; +@property (nonatomic, strong) NSString *replyToEndedPoll; @end @@ -43,6 +44,7 @@ - (instancetype)init _senderSentTheirLocation = @"has shared their location."; _senderSentTheirLiveLocation = @"Live location."; _messageToReplyToPrefix = @"In reply to"; + _replyToEndedPoll = @"Ended poll"; } return self; } diff --git a/MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h b/MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h index b28cdbd5b0..936b0ca667 100644 --- a/MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h +++ b/MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h @@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)senderSentTheirLocation; - (NSString *)senderSentTheirLiveLocation; - (NSString *)messageToReplyToPrefix; +- (NSString *)replyToEndedPoll; @end diff --git a/changelog.d/pr-1685.bugfix b/changelog.d/pr-1685.bugfix new file mode 100644 index 0000000000..5b466eee71 --- /dev/null +++ b/changelog.d/pr-1685.bugfix @@ -0,0 +1 @@ +Messages' replies: fix localizations issues.