Various fixes

This commit is contained in:
Ilya Laktyushin 2023-07-19 22:16:13 +02:00
parent f35d5ff3f5
commit 6fdd2ebf0d
3 changed files with 22 additions and 15 deletions

View File

@ -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...";

View File

@ -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)

View File

@ -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<String>()
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))