mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Translation fixes
This commit is contained in:
parent
23d3966576
commit
296b3ba788
@ -115,27 +115,32 @@ public func translateMessageIds(context: AccountContext, messageIds: [EngineMess
|
||||
var messageIdsToTranslate: [EngineMessage.Id] = []
|
||||
var messageIdsSet = Set<EngineMessage.Id>()
|
||||
for messageId in messageIds {
|
||||
guard !messageIdsSet.contains(messageId) else {
|
||||
continue
|
||||
}
|
||||
messageIdsSet.insert(messageId)
|
||||
if let message = transaction.getMessage(messageId) {
|
||||
if let replyAttribute = message.attributes.first(where: { $0 is ReplyMessageAttribute }) as? ReplyMessageAttribute, let replyMessage = message.associatedMessages[replyAttribute.messageId] {
|
||||
if !replyMessage.text.isEmpty {
|
||||
if let translation = replyMessage.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == toLang {
|
||||
} else {
|
||||
messageIdsToTranslate.append(replyMessage.id)
|
||||
if !messageIdsSet.contains(replyMessage.id) {
|
||||
messageIdsToTranslate.append(replyMessage.id)
|
||||
messageIdsSet.insert(replyMessage.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !message.text.isEmpty && message.author?.id != context.account.peerId {
|
||||
if let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == toLang {
|
||||
} else {
|
||||
messageIdsToTranslate.append(messageId)
|
||||
if !messageIdsSet.contains(messageId) {
|
||||
messageIdsToTranslate.append(messageId)
|
||||
messageIdsSet.insert(messageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageIdsToTranslate.append(messageId)
|
||||
if !messageIdsSet.contains(messageId) {
|
||||
messageIdsToTranslate.append(messageId)
|
||||
messageIdsSet.insert(messageId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return context.engine.messages.translateMessages(messageIds: messageIdsToTranslate, toLang: toLang)
|
||||
|
Loading…
x
Reference in New Issue
Block a user