From 55fb47078097c163336cbbf0b6ae91b00859b643 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 18 Jan 2023 11:06:13 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Remove=20localization=20of=20=E2=80=9CIn=20?= =?UTF-8?q?reply=20to=E2=80=9D=20when=20sending=20a=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MatrixSDK/Data/MXRoom.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index 020dbe5eef..7332c2c20d 100644 --- a/MatrixSDK/Data/MXRoom.m +++ b/MatrixSDK/Data/MXRoom.m @@ -2278,8 +2278,7 @@ - (void)getReplyContentBodiesWithEventToReply:(MXEvent*)eventToReply *replyContentFormattedBody = [self replyMessageFormattedBodyFromEventToReply:eventToReply senderMessageFormattedBody:senderMessageFormattedBody isSenderMessageAnEmote:isSenderMessageAnEmote - replyFormattedMessage:finalFormattedTextMessage - stringLocalizer:stringLocalizer]; + replyFormattedMessage:finalFormattedTextMessage]; } } @@ -2369,7 +2368,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 +2375,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 +2420,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) { From 581e33c35e0c38fa3b945cafb41715668f498f4b Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 18 Jan 2023 11:21:58 +0100 Subject: [PATCH 2/4] Add new requirement in MXSendReplyEventStringLocalizerProtocol --- MatrixSDK/Data/MXSendReplyEventStringLocalizerProtocol.h | 1 + 1 file changed, 1 insertion(+) 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 From 8be2b48ea3aa4623e64f460d3ad00f3094264a14 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 18 Jan 2023 11:30:16 +0100 Subject: [PATCH 3/4] Change text for replies to m.poll.end --- MatrixSDK/Data/MXRoom.m | 12 +++--------- .../Data/MXSendReplyEventDefaultStringLocalizer.m | 2 ++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/MatrixSDK/Data/MXRoom.m b/MatrixSDK/Data/MXRoom.m index 7332c2c20d..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) { 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; } From 4aa8c2241959f41e35142cd0c24a3cb2384a2e2f Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Wed, 18 Jan 2023 16:34:53 +0100 Subject: [PATCH 4/4] Add changelog.d file --- changelog.d/pr-1685.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-1685.bugfix 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.