From bc45193472cf22d0d1f05dff0e23c3584b6cc1b7 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 31 Oct 2024 20:25:35 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 17 +++++++++++++ .../Sources/ChatInputContextPanelNode.swift | 2 ++ .../Sources/GiftViewScreen.swift | 25 +++++-------------- .../Sources/ContextResultPanelComponent.swift | 9 +++---- .../Sources/PeerInfoScreen.swift | 1 - .../HashtagChatInputContextPanelNode.swift | 13 +++++----- ...textResultsChatInputContextPanelNode.swift | 4 --- ...rizontalStickersChatContextPanelNode.swift | 4 --- 8 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index d48b69cac1..c8c19facf4 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -13201,3 +13201,20 @@ Sorry for the inconvenience."; "Chat.ScheduledForceSendProcessingVideo.Title" = "Wait!"; "Chat.ScheduledForceSendProcessingVideo.Text" = "This video hasn't been converted and optimized yet. If you send it now, the viewers of the video may experience slow download speed."; "Chat.ScheduledForceSendProcessingVideo.Action" = "Send Anyway"; + +"Chat.HashtagSuggestion.UseGeneric.Title" = "Use %@"; +"Chat.HashtagSuggestion.UseGeneric.Text" = "searches posts from all channels"; + +"Chat.HashtagSuggestion.UseLocal.Title" = "Use %@"; +"Chat.HashtagSuggestion.UseLocal.Channel.Text" = "searches only posts from this channel"; +"Chat.HashtagSuggestion.UseLocal.Group.Text" = "searches only posts from this group"; + +"Gift.Convert.Period.Text" = "Do you want to convert this gift from **%1$@** to **%2$@**?\n\nConversion is available for the next %3$@.\n\nThis will permanently destroy the gift."; +"Gift.Convert.Period.Stars_1" = "%@ Star"; +"Gift.Convert.Period.Stars_any" = "%@ Stars"; +"Gift.Convert.Period.Days_1" = "%@ day"; +"Gift.Convert.Period.Days_any" = "%@ days"; + +"Gift.Convert.Period.Unavailable.Text" = "Sorry, you can't convert this gift.\n\nStars can only be claimed within %@ after receiving a gift."; +"Gift.Convert.Period.Unavailable.Days_1" = "%@ day"; +"Gift.Convert.Period.Unavailable.Days_any" = "%@ days"; diff --git a/submodules/TelegramUI/Components/Chat/ChatInputContextPanelNode/Sources/ChatInputContextPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatInputContextPanelNode/Sources/ChatInputContextPanelNode.swift index c6818c877d..29903c85f3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatInputContextPanelNode/Sources/ChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatInputContextPanelNode/Sources/ChatInputContextPanelNode.swift @@ -19,11 +19,13 @@ open class ChatInputContextPanelNode: ASDisplayNode { open var interfaceInteraction: ChatPanelInterfaceInteraction? open var placement: ChatInputContextPanelPlacement = .overPanels open var theme: PresentationTheme + open var strings: PresentationStrings open var fontSize: PresentationFontSize public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, chatPresentationContext: ChatPresentationContext) { self.context = context self.theme = theme + self.strings = strings self.fontSize = fontSize super.init() diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index 6ac2b53c30..e460827545 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -557,7 +557,7 @@ private final class GiftViewSheetContent: CombinedComponent { )) } - if savedToProfile { + if incoming && savedToProfile { tableItems.append(.init( id: "visibility", title: strings.Gift_View_Visibility, @@ -1028,19 +1028,11 @@ public class GiftViewScreen: ViewControllerComponentContainer { let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) if currentTime > starsConvertMaxDate { - //TODO:localize - - let duration: String - if starsConvertMaxDate == 300 { - duration = "5 minutes" - } else { - duration = "90 days" - } - + let days: Int32 = Int32(ceil(Float(configuration.convertToStarsPeriod) / 86400.0)) let controller = textAlertController( context: self.context, title: presentationData.strings.Gift_Convert_Title, - text: "Sorry, you can't convert this gift.\n\nStars can only be claimed within \(duration) after receiving a gift.", + text: presentationData.strings.Gift_Convert_Period_Unavailable_Text(presentationData.strings.Gift_Convert_Period_Unavailable_Days(days)).string, actions: [ TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {}) ], @@ -1049,14 +1041,9 @@ public class GiftViewScreen: ViewControllerComponentContainer { self.present(controller, in: .window(.root)) } else { let delta = starsConvertMaxDate - currentTime - let duration: String - if starsConvertMaxDate == 300 { - duration = "\(delta / 60) minutes" - } else { - duration = "\(delta / 86400) days" - } - //TODO:localize - let text = "Do you want to convert this gift from **\(fromPeerName)** to **\(presentationData.strings.Gift_Convert_Stars(Int32(arguments.convertStars)))**?\n\nConversion is available for the next \(duration).\n\nThis will permanently destroy the gift." + let days: Int32 = Int32(ceil(Float(delta) / 86400.0)) + + let text = presentationData.strings.Gift_Convert_Period_Text(fromPeerName, presentationData.strings.Gift_Convert_Period_Stars(Int32(arguments.convertStars)), presentationData.strings.Gift_Convert_Period_Days(days)).string let controller = textAlertController( context: self.context, title: presentationData.strings.Gift_Convert_Title, diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift index 956f088e41..39afb61744 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/ContextResultPanelComponent.swift @@ -233,7 +233,6 @@ final class ContextResultPanelComponent: Component { } if let peer, let addressName = peer.addressName, hashtagIndex < 0 { - //TODO: localize var isGroup = false if case let .channel(channel) = peer, case .group = channel.info { isGroup = true @@ -245,8 +244,8 @@ final class ContextResultPanelComponent: Component { theme: component.theme, strings: component.strings, peer: nil, - title: "Use #\(query)", - subtitle: "searches posts from all channels", + title: component.strings.Chat_HashtagSuggestion_UseGeneric_Title("#\(query)").string, + subtitle: component.strings.Chat_HashtagSuggestion_UseGeneric_Text, hashtag: query, hasNext: index != hashtags.count - 1, action: { [weak self] hashtag, _ in @@ -262,8 +261,8 @@ final class ContextResultPanelComponent: Component { theme: component.theme, strings: component.strings, peer: peer, - title: "Use #\(query)@\(addressName)", - subtitle: isGroup ? "searches only posts from this group" : "searches only posts from this channel", + title: component.strings.Chat_HashtagSuggestion_UseLocal_Title("#\(query)@\(addressName)").string, + subtitle: isGroup ? component.strings.Chat_HashtagSuggestion_UseLocal_Group_Text : component.strings.Chat_HashtagSuggestion_UseLocal_Channel_Text, hashtag: "\(query)@\(addressName)", hasNext: index != hashtags.count - 1, action: { [weak self] hashtag, _ in diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 1c97f1bf09..6354ffbb83 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -1513,7 +1513,6 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese let overallStarsBalance = data.starsRevenueStatsState?.balances.overallRevenue ?? 0 if overallRevenueBalance > 0 || overallStarsBalance > 0 { - //TODO:localize items[.balances]!.append(PeerInfoScreenHeaderItem(id: 20, text: presentationData.strings.PeerInfo_BotBalance_Title)) if overallRevenueBalance > 0 { let string = "*\(formatTonAmountText(revenueBalance, dateTimeFormat: presentationData.dateTimeFormat))" diff --git a/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift index 943a4ab4c4..fe3ac7c4fe 100644 --- a/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/HashtagChatInputContextPanelNode.swift @@ -120,15 +120,14 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode { if let peer, let _ = peer.addressName { isAdditionalRecent = true } - //TODO:localize - if query.count > 3 { + if query.count >= 4 { if let peer, let addressName = peer.addressName { let genericEntry = HashtagChatInputContextPanelEntry( index: 0, theme: self.theme, peer: nil, - title: "Use #\(query)", - text: "searches posts from all channels", + title: self.strings.Chat_HashtagSuggestion_UseGeneric_Title("#\(query)").string, + text: self.strings.Chat_HashtagSuggestion_UseGeneric_Text, badge: nil, hashtag: query, revealed: false, @@ -145,9 +144,9 @@ final class HashtagChatInputContextPanelNode: ChatInputContextPanelNode { index: 1, theme: self.theme, peer: peer, - title: "Use #\(query)@\(addressName)", - text: isGroup ? "searches only posts from this group" : "searches only posts from this channel", - badge: "NEW", + title: self.strings.Chat_HashtagSuggestion_UseLocal_Title("#\(query)@\(addressName)").string, + text: isGroup ? self.strings.Chat_HashtagSuggestion_UseLocal_Group_Text : self.strings.Chat_HashtagSuggestion_UseLocal_Channel_Text, + badge: self.strings.ChatList_ContextMenuBadgeNew, hashtag: "\(query)@\(addressName)", revealed: false, isAdditionalRecent: false diff --git a/submodules/TelegramUI/Sources/HorizontalListContextResultsChatInputContextPanelNode.swift b/submodules/TelegramUI/Sources/HorizontalListContextResultsChatInputContextPanelNode.swift index 0099449916..dd14e47777 100644 --- a/submodules/TelegramUI/Sources/HorizontalListContextResultsChatInputContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/HorizontalListContextResultsChatInputContextPanelNode.swift @@ -82,8 +82,6 @@ private func preparedTransition(from fromEntries: [HorizontalListContextResultsC } final class HorizontalListContextResultsChatInputContextPanelNode: ChatInputContextPanelNode { - private var strings: PresentationStrings - private let listView: ListView private let separatorNode: ASDisplayNode private var currentExternalResults: ChatContextResultCollection? @@ -96,8 +94,6 @@ final class HorizontalListContextResultsChatInputContextPanelNode: ChatInputCont private var hasValidLayout = false override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, chatPresentationContext: ChatPresentationContext) { - self.strings = strings - self.separatorNode = ASDisplayNode() self.separatorNode.isLayerBacked = true self.separatorNode.backgroundColor = theme.list.itemPlainSeparatorColor diff --git a/submodules/TelegramUI/Sources/HorizontalStickersChatContextPanelNode.swift b/submodules/TelegramUI/Sources/HorizontalStickersChatContextPanelNode.swift index 8d934b11f3..2f530668a3 100755 --- a/submodules/TelegramUI/Sources/HorizontalStickersChatContextPanelNode.swift +++ b/submodules/TelegramUI/Sources/HorizontalStickersChatContextPanelNode.swift @@ -103,8 +103,6 @@ private func preparedGridEntryTransition(context: AccountContext, from fromEntri } final class HorizontalStickersChatContextPanelNode: ChatInputContextPanelNode { - private var strings: PresentationStrings - private let backgroundLeftNode: ASImageNode private let backgroundNode: ASImageNode private let backgroundRightNode: ASImageNode @@ -121,8 +119,6 @@ final class HorizontalStickersChatContextPanelNode: ChatInputContextPanelNode { private var stickerPreviewController: StickerPreviewController? override init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, fontSize: PresentationFontSize, chatPresentationContext: ChatPresentationContext) { - self.strings = strings - self.backgroundNode = ASImageNode() self.backgroundNode.displayWithoutProcessing = true self.backgroundNode.displaysAsynchronously = false