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