From 6fdd2ebf0dfe66e79a6448dd06d82ca7f37b12bc Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 19 Jul 2023 22:16:13 +0200 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 9 ++++----- .../Sources/MediaEditorScreen.swift | 13 ++++++------- submodules/TranslateUI/Sources/Translate.swift | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index ac2ad35005..7be547efa2 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -9552,9 +9552,9 @@ Sorry for the inconvenience."; "Story.ContextDeleteStory" = "Delete Story"; -"Story.TooltipPrivacyCloseFriends" = "You are seeing this story because you have\nbeen added to %@'s list of close friends."; -"Story.TooltipPrivacyContacts" = "Only %@'s contacts can view this story."; -"Story.TooltipPrivacySelectedContacts" = "Only some contacts %@ selected can view this story."; +"Story.TooltipPrivacyCloseFriends" = "You are seeing this story because you have\nbeen added to **%@'s** list of close friends."; +"Story.TooltipPrivacyContacts" = "Only **%@'s** contacts can view this story."; +"Story.TooltipPrivacySelectedContacts" = "Only some contacts **%@** selected can view this story."; "Story.ToastViewInChat" = "View in Chat"; "Story.ToastReactionSent" = "Reaction Sent."; @@ -9629,8 +9629,7 @@ Sorry for the inconvenience."; "Story.Editor.ExpirationValue_1" = "1 Hour"; "Story.Editor.ExpirationValue_any" = "%d Hours"; -"Story.Editor.TooltipPremiumCustomExpiration" = "Subscribe to **Telegram Premium** to make your stories disappear %@."; -"Story.Editor.TooltipPremiumMore" = "More"; +"Story.Editor.TooltipPremiumExpiration" = "Subscribe to **Telegram Premium** to make your stories disappear after 6, 12 or 48 hours."; "Story.Editor.InputPlaceholderAddCaption" = "Add a caption..."; diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index d799c6d0e5..7624f578ef 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -3454,7 +3454,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate if hasPremium { updateTimeout(3600 * 6) } else { - self?.presentTimeoutPremiumSuggestion(3600 * 6) + self?.presentTimeoutPremiumSuggestion() } }))) items.append(.action(ContextMenuActionItem(text: presentationData.strings.Story_Editor_ExpirationValue(12), icon: { theme in @@ -3469,7 +3469,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate if hasPremium { updateTimeout(3600 * 12) } else { - self?.presentTimeoutPremiumSuggestion(3600 * 12) + self?.presentTimeoutPremiumSuggestion() } }))) items.append(.action(ContextMenuActionItem(text: presentationData.strings.Story_Editor_ExpirationValue(24), icon: { theme in @@ -3491,7 +3491,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate if hasPremium { updateTimeout(86400 * 2) } else { - self?.presentTimeoutPremiumSuggestion(86400 * 2) + self?.presentTimeoutPremiumSuggestion() } }))) @@ -3499,14 +3499,13 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.present(contextController, in: .window(.root)) } - private func presentTimeoutPremiumSuggestion(_ timeout: Int32) { + private func presentTimeoutPremiumSuggestion() { let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } - let timeoutString = presentationData.strings.MuteExpires_Hours(max(1, timeout / (60 * 60))) - let text = presentationData.strings.Story_Editor_TooltipPremiumCustomExpiration(timeoutString).string + let text = presentationData.strings.Story_Editor_TooltipPremiumExpiration let context = self.context - let controller = UndoOverlayController(presentationData: presentationData, content: .autoDelete(isOn: true, title: nil, text: text, customUndoText: presentationData.strings.Story_Editor_TooltipPremiumMore), elevatedLayout: false, position: .top, animateInAsReplacement: false, action: { [weak self] action in + let controller = UndoOverlayController(presentationData: presentationData, content: .autoDelete(isOn: true, title: nil, text: text, customUndoText: nil), elevatedLayout: false, position: .top, animateInAsReplacement: false, action: { [weak self] action in if case .undo = action, let self { let controller = context.sharedContext.makePremiumIntroController(context: context, source: .settings) self.push(controller) diff --git a/submodules/TranslateUI/Sources/Translate.swift b/submodules/TranslateUI/Sources/Translate.swift index 5a70f375ce..5b52b36413 100644 --- a/submodules/TranslateUI/Sources/Translate.swift +++ b/submodules/TranslateUI/Sources/Translate.swift @@ -148,11 +148,20 @@ public func canTranslateText(context: AccountContext, text: String, showTranslat return (true, nil) } - var dontTranslateLanguages: [String] = [] + var baseLang = context.sharedContext.currentPresentationData.with { $0 }.strings.baseLanguageCode + let rawSuffix = "-raw" + if baseLang.hasSuffix(rawSuffix) { + baseLang = String(baseLang.dropLast(rawSuffix.count)) + } + + var dontTranslateLanguages = Set() if let ignoredLanguages = ignoredLanguages { - dontTranslateLanguages = ignoredLanguages + dontTranslateLanguages = Set(ignoredLanguages) } else { - dontTranslateLanguages = [context.sharedContext.currentPresentationData.with { $0 }.strings.baseLanguageCode] + dontTranslateLanguages.insert(baseLang) + for language in systemLanguageCodes() { + dontTranslateLanguages.insert(language) + } } let text = String(text.prefix(64))