diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 2c0c0a5816..74034789c8 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -14507,9 +14507,6 @@ Sorry for the inconvenience."; "Attachment.DiscardTodoAlertText" = "Discard checklist items?"; -"Auth.PremiumSignUp.ActionTitle" = "Sign up for %@"; -"Auth.PremiumSignUp.ActionSubtitle" = "Get Telegram Premium for 1 week"; - "Chat.PostApproval.Status.AdminApproved" = "The message was approved"; "Chat.PostApproval.Status.AdminRejected" = "The message was rejected"; "Chat.PostApproval.Status.UserApproved" = "Your message was approved"; diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 96740391cc..e7f0cf797a 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -1644,8 +1644,10 @@ public struct TranslationConfiguration { public static func with(appConfiguration: AppConfiguration) -> TranslationConfiguration { if let data = appConfiguration.data { let manualValue = data["translations_manual_enabled"] as? String ?? "disabled" - let autoValue = data["translations_auto_enabled"] as? String ?? "disabled" - + var autoValue = data["translations_auto_enabled"] as? String ?? "disabled" + if autoValue == "alternative" { + autoValue = "disabled" + } return TranslationConfiguration(manual: TranslationAvailability(string: manualValue), auto: TranslationAvailability(string: autoValue)) } else { return .defaultValue diff --git a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift index c65c18dde9..4c582e1ed6 100644 --- a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift @@ -1126,6 +1126,7 @@ private final class DemoSheetContent: CombinedComponent { content: AnyComponent(PhoneDemoComponent( context: component.context, position: .top, + model: .island, videoFile: configuration.videos["todo"], decoration: .todo )), diff --git a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift index 32ce09dad0..858a67f7ce 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitsListScreen.swift @@ -870,6 +870,7 @@ public class PremiumLimitsListScreen: ViewController { content: AnyComponent(PhoneDemoComponent( context: context, position: .top, + model: .island, videoFile: videos["todo"], decoration: .todo )), diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index d70e5ecc2b..082ec3e597 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -6616,7 +6616,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro } } - if let cachedData = data.cachedData as? CachedUserData, cachedData.flags.contains(.translationHidden) { + if let cachedData = data.cachedData as? CachedUserData, canTranslateChats(context: strongSelf.context), cachedData.flags.contains(.translationHidden) { items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ContextMenuTranslate, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Translate"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in diff --git a/submodules/TranslateUI/Sources/ChatTranslation.swift b/submodules/TranslateUI/Sources/ChatTranslation.swift index bef45d63c7..fdcb75f884 100644 --- a/submodules/TranslateUI/Sources/ChatTranslation.swift +++ b/submodules/TranslateUI/Sources/ChatTranslation.swift @@ -193,6 +193,10 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id, return .single(nil) } + guard canTranslateChats(context: context) else { + return .single(nil) + } + let loggingEnabled = context.sharedContext.immediateExperimentalUISettings.logLanguageRecognition if #available(iOS 12.0, *) { diff --git a/submodules/TranslateUI/Sources/Translate.swift b/submodules/TranslateUI/Sources/Translate.swift index 9c9d211952..f587da8b5d 100644 --- a/submodules/TranslateUI/Sources/Translate.swift +++ b/submodules/TranslateUI/Sources/Translate.swift @@ -171,6 +171,23 @@ public func normalizeTranslationLanguage(_ code: String) -> String { return code } +public func canTranslateChats(context: AccountContext) -> Bool { + let translationConfiguration = TranslationConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) + var chatTranslationAvailable = true + switch translationConfiguration.auto { + case .system: + if #available(iOS 18.0, *) { + } else { + chatTranslationAvailable = false + } + case .alternative, .disabled: + chatTranslationAvailable = false + default: + break + } + return chatTranslationAvailable +} + public func canTranslateText(context: AccountContext, text: String, showTranslate: Bool, showTranslateIfTopical: Bool = false, ignoredLanguages: [String]?) -> (canTranslate: Bool, language: String?) { guard showTranslate || showTranslateIfTopical, text.count > 0 else { return (false, nil) @@ -298,7 +315,7 @@ private struct TranslationViewImpl: View { var resultMap: [AnyHashable: String] = [:] for response in responses { if let clientIdentifier = response.clientIdentifier, let originalKey = clientIdentifierMap[clientIdentifier] { - resultMap[originalKey] = "\(response.targetText)" + resultMap[originalKey] = "\(response.targetText)" } } @@ -494,11 +511,6 @@ func alternativeTranslateText(text: String, fromLang: String?, toLang: String) - return } -// var sourceLanguage: String? = nil -// if jsonArray.count > 2, let lang = jsonArray[2] as? String { -// sourceLanguage = lang.contains("-") ? String(lang.prefix(while: { $0 != "-" })) : lang -// } - var result = "" for element in translationArray { if let translationBlock = element as? [Any], @@ -530,8 +542,6 @@ func alternativeTranslateText(text: String, fromLang: String?, toLang: String) - func getRandomUserAgent() -> String { let userAgents = [ - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15", "Mozilla/5.0 (iPhone; CPU iPhone OS 18_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.4 Mobile/15E148 Safari/604.1" ] return userAgents.randomElement() ?? userAgents[0]