Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Jul 19, 2023
1 parent f35d5ff commit 6fdd2eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
9 changes: 4 additions & 5 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down Expand Up @@ -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...";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -3491,22 +3491,21 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
if hasPremium {
updateTimeout(86400 * 2)
} else {
self?.presentTimeoutPremiumSuggestion(86400 * 2)
self?.presentTimeoutPremiumSuggestion()
}
})))

let contextController = ContextController(account: self.context.account, presentationData: presentationData, source: .reference(HeaderContextReferenceContentSource(controller: self, sourceView: sourceView)), items: .single(ContextController.Items(content: .list(items))), gesture: nil)
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)
Expand Down
15 changes: 12 additions & 3 deletions submodules/TranslateUI/Sources/Translate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 6fdd2eb

Please sign in to comment.