Skip to content

Commit 3f12448

Browse files
committed
Various fixes
1 parent d43f05d commit 3f12448

File tree

9 files changed

+94
-63
lines changed

9 files changed

+94
-63
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13887,7 +13887,11 @@ Sorry for the inconvenience.";
1388713887

1388813888
"Chat.NonContactUser.UpdatedName" = "User updated name %1$@";
1388913889
"Chat.NonContactUser.UpdatedPhoto" = "User updated photo %1$@";
13890-
"Chat.NonContactUser.UpdatedToday" = "today";
13890+
13891+
"Chat.NonContactUser.UpdatedMinutes_1" = "%@ minute ago";
13892+
"Chat.NonContactUser.UpdatedMinutes_any" = "%@ minutes ago";
13893+
"Chat.NonContactUser.UpdatedHours_1" = "%@ hour ago";
13894+
"Chat.NonContactUser.UpdatedHours_any" = "%@ hours ago";
1389113895
"Chat.NonContactUser.UpdatedDays_1" = "%@ day ago";
1389213896
"Chat.NonContactUser.UpdatedDays_any" = "%@ days ago";
1389313897

@@ -13933,3 +13937,39 @@ Sorry for the inconvenience.";
1393313937
"PeerInfo.Gifts.ToastUnpinned.Text" = "Gift Unpinned.";
1393413938
"PeerInfo.Gifts.ToastPinned.Title" = "Gift Pinned";
1393513939
"PeerInfo.Gifts.ToastPinned.Text" = "Now it will always be shown on the top.";
13940+
13941+
"Chat.PaidMessage.Confirm.Title" = "Confirm Payment";
13942+
"Chat.PaidMessage.Confirm.DontAskAgain" = "Don't ask again";
13943+
"Chat.PaidMessage.Confirm.PayForMessage_1" = "Pay for %@ Message";
13944+
"Chat.PaidMessage.Confirm.PayForMessage_any" = "Pay for %@ Messages";
13945+
"Chat.PaidMessage.Confirm.Single.Text" = "**%1$@** charges **%2$@** per incoming message. Would you like to pay **%3$@** to send %4$@?";
13946+
"Chat.PaidMessage.Confirm.Multiple.Text" = "You selected %1$@ who charge Stars for messages. Would you like to pay **%2$@** Stars to send %3$@?";
13947+
"Chat.PaidMessage.Confirm.Text.Users_1" = "**%@** user";
13948+
"Chat.PaidMessage.Confirm.Text.Users_any" = "**%@** users";
13949+
"Chat.PaidMessage.Confirm.Text.Messages_1" = "**%@** message";
13950+
"Chat.PaidMessage.Confirm.Text.Messages_any" = "**%@** messages";
13951+
"Chat.PaidMessage.Confirm.Text.Stars_1" = "%@ Star";
13952+
"Chat.PaidMessage.Confirm.Text.Stars_any" = "%@ Stars";
13953+
13954+
"Chat.PaidMessage.RemoveFee.Title" = "Remove Fee";
13955+
"Chat.PaidMessage.RemoveFee.Text" = "Are you sure you want to allow **%@** to message you for free?";
13956+
"Chat.PaidMessage.RemoveFee.Yes" = "Yes";
13957+
"Chat.PaidMessage.RemoveFee.Refund" = "Refund already paid **%@**";
13958+
"Chat.PaidMessage.RemoveFee.Refund.Stars_1" = "%@ Star";
13959+
"Chat.PaidMessage.RemoveFee.Refund.Stars_any" = "%@ Stars";
13960+
13961+
"Chat.PaidMessage.Sent.Title_1" = "Message Sent";
13962+
"Chat.PaidMessage.Sent.Title_any" = "%@ Messages Sent";
13963+
"Chat.PaidMessage.Sent.Text" = "You paid %@";
13964+
"Chat.PaidMessage.Sent.Text.Stars_1" = "%@ Star";
13965+
"Chat.PaidMessage.Sent.Text.Stars_any" = "%@ Stars";
13966+
13967+
"Chat.PaidMessageFee.Text" = "%1$@ must pay %2$@ for each message to you.";
13968+
"Chat.PaidMessageFee.RemoveFee" = "Remove Fee";
13969+
13970+
"Privacy.Review.Review" = "Review";
13971+
"Privacy.Review.Calls.Title" = "Call Settings";
13972+
"Privacy.Review.Calls.Text" = "You've restricted who can message you, but anyone can still call you. Would you like to review these settings?";
13973+
13974+
"Privacy.Review.Invite.Title" = "Invitation Settings";
13975+
"Privacy.Review.Invite.Text" = "You've restricted who can message you, but anyone can still invite you to groups and channels. Would you like to review these settings?";

submodules/AttachmentTextInputPanelNode/Sources/AttachmentTextInputPanelNode.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -973,19 +973,19 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
973973
text = presentationInterfaceState.strings.MediaPicker_Send
974974
}
975975
actionButtonsSize = self.actionButtons.updateLayout(size: CGSize(width: 44.0, height: minimalHeight), transition: transition, minimized: isMinimized, text: text, interfaceState: presentationInterfaceState)
976-
textBackgroundInset = 44.0 - actionButtonsSize.width
976+
textBackgroundInset = actionButtonsSize.width - 44.0
977977
} else {
978978
actionButtonsSize = CGSize(width: 44.0, height: minimalHeight)
979979
}
980980

981981
let actionButtonsFrame = CGRect(origin: CGPoint(x: width - rightInset - actionButtonsSize.width + 1.0 - UIScreenPixel + composeButtonsOffset, y: panelHeight - minimalHeight), size: actionButtonsSize)
982982
transition.updateFrame(node: self.actionButtons, frame: actionButtonsFrame)
983983

984-
let textInputBackgroundFrame = CGRect(origin: CGPoint(), size: CGSize(width: textInputFrame.size.width + composeButtonsOffset + textBackgroundInset, height: textInputFrame.size.height))
984+
let textInputBackgroundFrame = CGRect(origin: CGPoint(), size: CGSize(width: textInputFrame.size.width + composeButtonsOffset, height: textInputFrame.size.height))
985985
transition.updateFrame(node: self.textInputContainerBackgroundNode, frame: textInputBackgroundFrame)
986986

987-
transition.updateFrame(layer: self.textInputBackgroundNode.layer, frame: CGRect(x: leftInset + textFieldInsets.left, y: textFieldInsets.top, width: baseWidth - textFieldInsets.left - textFieldInsets.right + composeButtonsOffset + textBackgroundInset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom))
988-
transition.updateFrame(layer: self.textInputBackgroundImageNode.layer, frame: CGRect(x: 0.0, y: 0.0, width: baseWidth - textFieldInsets.left - textFieldInsets.right + composeButtonsOffset + textBackgroundInset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom))
987+
transition.updateFrame(layer: self.textInputBackgroundNode.layer, frame: CGRect(x: leftInset + textFieldInsets.left, y: textFieldInsets.top, width: baseWidth - textFieldInsets.left - textFieldInsets.right + composeButtonsOffset - textBackgroundInset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom))
988+
transition.updateFrame(layer: self.textInputBackgroundImageNode.layer, frame: CGRect(x: 0.0, y: 0.0, width: baseWidth - textFieldInsets.left - textFieldInsets.right + composeButtonsOffset - textBackgroundInset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom))
989989

990990
var textInputViewRealInsets = UIEdgeInsets()
991991
if let presentationInterfaceState = self.presentationInterfaceState {

submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,16 +1470,15 @@ public func privacyAndSecurityController(
14701470
}
14711471

14721472
showPrivacySuggestionImpl = {
1473-
//TODO:localize
14741473
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
14751474
if reviewCallPrivacySuggestion {
14761475
reviewCallPrivacySuggestion = false
14771476
let alertController = textAlertController(
14781477
context: context,
1479-
title: "Call Settings",
1480-
text: "You've restricted who can message you, but anyone can still call you. Would you like to review these settings?",
1478+
title: presentationData.strings.Privacy_Review_Calls_Title,
1479+
text: presentationData.strings.Privacy_Review_Calls_Text,
14811480
actions: [
1482-
TextAlertAction(type: .defaultAction, title: "Review", action: {
1481+
TextAlertAction(type: .defaultAction, title: presentationData.strings.Privacy_Review_Review, action: {
14831482
arguments.openVoiceCallPrivacy()
14841483
}),
14851484
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
@@ -1495,10 +1494,10 @@ public func privacyAndSecurityController(
14951494
reviewInvitePrivacySuggestion = false
14961495
let alertController = textAlertController(
14971496
context: context,
1498-
title: "Invitation Settings",
1499-
text: "You've restricted who can message you, but anyone can still invite you to groups and channels. Would you like to review these settings?",
1497+
title: presentationData.strings.Privacy_Review_Invite_Title,
1498+
text: presentationData.strings.Privacy_Review_Invite_Text,
15001499
actions: [
1501-
TextAlertAction(type: .defaultAction, title: "Review", action: {
1500+
TextAlertAction(type: .defaultAction, title: presentationData.strings.Privacy_Review_Review, action: {
15021501
arguments.openGroupsPrivacy()
15031502
}),
15041503
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {

submodules/TelegramStringFormatting/Sources/PresenceStrings.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,15 @@ public func stringForRemainingMuteInterval(strings: PresentationStrings, muteInt
659659
return strings.MuteExpires_Days(Int32(round(Float(value) / (24 * 60 * 60))))
660660
}
661661
}
662+
663+
public func stringForIntervalSinceUpdateAction(strings: PresentationStrings, value: Int32) -> String {
664+
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
665+
let value = max(1 * 60, timestamp - value)
666+
if value <= 1 * 60 * 60 {
667+
return strings.Chat_NonContactUser_UpdatedMinutes(Int32(round(Float(value) / 60)))
668+
} else if value <= 24 * 60 * 60 {
669+
return strings.Chat_NonContactUser_UpdatedHours(Int32(round(Float(value) / (60 * 60))))
670+
} else {
671+
return strings.Chat_NonContactUser_UpdatedDays(Int32(round(Float(value) / (24 * 60 * 60))))
672+
}
673+
}

submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,7 @@ final class AvatarEditorScreenComponent: Component {
12831283
case .suggest:
12841284
buttonText = strings.AvatarEditor_SuggestProfilePhoto
12851285
case .user:
1286-
//TODO:localize
1287-
buttonText = "Set My Photo" //strings.AvatarEditor_SetProfilePhoto
1286+
buttonText = strings.AvatarEditor_SetProfilePhoto
12881287
case .group, .forum:
12891288
buttonText = strings.AvatarEditor_SetGroupPhoto
12901289
case .channel:

submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -424,35 +424,30 @@ public func chatMessagePaymentAlertController(
424424
var completionImpl: (() -> Void)?
425425
var dismissImpl: (() -> Void)?
426426

427-
//TODO:localize
428-
let title = "Confirm Payment"
429-
let actionTitle: String
430-
let messagesString: String
431-
if count > 1 {
432-
messagesString = "**\(count)** messages"
433-
actionTitle = "Pay for \(count) Messages"
434-
} else {
435-
messagesString = "**\(count)** message"
436-
actionTitle = "Pay for 1 Message"
437-
}
427+
let title = presentationData.strings.Chat_PaidMessage_Confirm_Title
428+
let actionTitle = presentationData.strings.Chat_PaidMessage_Confirm_PayForMessage(count)
429+
let messagesString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Messages(count)
438430

439431
let actions: [TextAlertAction] = [TextAlertAction(type: .defaultAction, title: actionTitle, action: {
440432
completionImpl?()
441433
dismissImpl?()
442434
}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
443435
dismissImpl?()
444436
})]
445-
446437

447438
let text: String
448439
if peers.count == 1, let peer = peers.first {
449-
text = "**\(peer.compactDisplayTitle)** charges **\(amount.value) Stars** per incoming message. Would you like to pay **\(amount.value * Int64(count)) Stars** to send \(messagesString)?"
440+
let amountString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Stars(Int32(amount.value))
441+
let totalString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Stars(Int32(amount.value * Int64(count)))
442+
text = presentationData.strings.Chat_PaidMessage_Confirm_Single_Text(peer.compactDisplayTitle, amountString, totalString, messagesString).string
450443
} else {
451444
let amount = totalAmount ?? amount
452-
text = "You selected **\(peers.count)** users who charge Stars for messages. Would you like to pay **\(amount.value)** Stars to send \(messagesString)?"
445+
let usersString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Users(Int32(peers.count))
446+
let totalString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Stars(Int32(amount.value * Int64(count)))
447+
text = presentationData.strings.Chat_PaidMessage_Confirm_Multiple_Text(usersString, totalString, messagesString).string
453448
}
454449

455-
let optionText = hasCheck ? "Don't ask again" : nil
450+
let optionText = hasCheck ? presentationData.strings.Chat_PaidMessage_Confirm_DontAskAgain : nil
456451

457452
let contentNode = ChatMessagePaymentAlertContentNode(theme: AlertControllerTheme(presentationData: presentationData), ptheme: theme, strings: strings, title: title, text: text, optionText: optionText, actions: actions, alignment: .vertical)
458453

@@ -470,8 +465,6 @@ public func chatMessagePaymentAlertController(
470465
return controller
471466
}
472467

473-
474-
475468
public func chatMessageRemovePaymentAlertController(
476469
context: AccountContext? = nil,
477470
presentationData: PresentationData,
@@ -488,20 +481,19 @@ public func chatMessageRemovePaymentAlertController(
488481
var completionImpl: (() -> Void)?
489482
var dismissImpl: (() -> Void)?
490483

491-
//TODO:localize
492484
let actions: [TextAlertAction] = [
493-
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
485+
TextAlertAction(type: .genericAction, title: strings.Common_Cancel, action: {
494486
dismissImpl?()
495487
}),
496-
TextAlertAction(type: .defaultAction, title: "Yes", action: {
488+
TextAlertAction(type: .defaultAction, title: strings.Chat_PaidMessage_RemoveFee_Yes, action: {
497489
completionImpl?()
498490
dismissImpl?()
499491
})
500492
]
501493

502-
let title = "Remove Fee"
503-
let text = "Are you sure you want to allow **\(peer.compactDisplayTitle)** to message you for free?"
504-
let optionText = amount.flatMap { "Refund already paid **\($0.value) Stars**" }
494+
let title = strings.Chat_PaidMessage_RemoveFee_Title
495+
let text = strings.Chat_PaidMessage_RemoveFee_Text(peer.compactDisplayTitle).string
496+
let optionText = amount.flatMap { strings.Chat_PaidMessage_RemoveFee_Refund(strings.Chat_PaidMessage_RemoveFee_Refund_Stars(Int32($0.value))).string }
505497

506498
let contentNode = ChatMessagePaymentAlertContentNode(theme: AlertControllerTheme(presentationData: presentationData), ptheme: theme, strings: strings, title: title, text: text, optionText: optionText, actions: actions, alignment: .horizontal)
507499

submodules/TelegramUI/Sources/Chat/ChatControllerPaidMessage.swift

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ extension ChatControllerImpl {
2121
return
2222
}
2323
if let sendPaidMessageStars = self.presentationInterfaceState.sendPaidMessageStars {
24+
let totalAmount = sendPaidMessageStars.value * Int64(count)
25+
2426
let _ = (ApplicationSpecificNotice.dismissedPaidMessageWarningNamespace(accountManager: self.context.sharedContext.accountManager, peerId: peer.id)
2527
|> deliverOnMainQueue).start(next: { [weak self] dismissedAmount in
2628
guard let self, let starsContext = self.context.starsContext else {
2729
return
2830
}
29-
if let dismissedAmount, dismissedAmount == sendPaidMessageStars.value, let currentState = starsContext.currentState, currentState.balance > sendPaidMessageStars {
31+
if let dismissedAmount, dismissedAmount == sendPaidMessageStars.value, let currentState = starsContext.currentState, currentState.balance.value > totalAmount, count < 3 && totalAmount < 100 {
3032
completion(true)
3133
self.displayPaidMessageUndo(count: count, amount: sendPaidMessageStars)
3234
} else {
@@ -52,14 +54,14 @@ extension ChatControllerImpl {
5254
let _ = ApplicationSpecificNotice.setDismissedPaidMessageWarningNamespace(accountManager: self.context.sharedContext.accountManager, peerId: peer.id, amount: sendPaidMessageStars.value).start()
5355
}
5456

55-
if let currentState = starsContext.currentState, currentState.balance < sendPaidMessageStars {
57+
if let currentState = starsContext.currentState, currentState.balance.value < totalAmount {
5658
let _ = (self.context.engine.payments.starsTopUpOptions()
5759
|> take(1)
5860
|> deliverOnMainQueue).startStandalone(next: { [weak self] options in
5961
guard let self else {
6062
return
6163
}
62-
let controller = self.context.sharedContext.makeStarsPurchaseScreen(context: self.context, starsContext: starsContext, options: options, purpose: .sendMessage(peerId: peer.id, requiredStars: sendPaidMessageStars.value), completion: { _ in
64+
let controller = self.context.sharedContext.makeStarsPurchaseScreen(context: self.context, starsContext: starsContext, options: options, purpose: .sendMessage(peerId: peer.id, requiredStars: totalAmount), completion: { _ in
6365
completion(false)
6466
})
6567
self.push(controller)
@@ -89,18 +91,11 @@ extension ChatControllerImpl {
8991
self.context.engine.messages.forceSendPostponedPaidMessage(peerId: peerId)
9092
}
9193

92-
//TODO:localize
93-
let title: String
94-
if count > 1 {
95-
title = "\(count) Messages Sent"
96-
} else {
97-
title = "Message Sent"
98-
}
99-
94+
let title = self.presentationData.strings.Chat_PaidMessage_Sent_Title(count)
95+
let text = self.presentationData.strings.Chat_PaidMessage_Sent_Text(self.presentationData.strings.Chat_PaidMessage_Sent_Text_Stars(Int32(amount.value * Int64(count)))).string
10096
let textItems: [AnimatedTextComponent.Item] = [
101-
AnimatedTextComponent.Item(id: 0, content: .text("You paid \(amount.value * Int64(count)) Stars"))
97+
AnimatedTextComponent.Item(id: 0, content: .text(text))
10298
]
103-
10499
let controller = UndoOverlayController(presentationData: self.presentationData, content: .starsSent(context: self.context, title: title, text: textItems), elevatedLayout: false, position: .top, action: { [weak self] action in
105100
guard let self else {
106101
return false

submodules/TelegramUI/Sources/ChatFeePanelNode.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ final class ChatFeePanelNode: ASDisplayNode {
8989
if self.theme !== interfaceState.theme {
9090
self.theme = interfaceState.theme
9191
self.separatorNode.backgroundColor = interfaceState.theme.rootController.navigationBar.separatorColor
92-
//TODO:localize
93-
self.removeTextNode.attributedText = NSAttributedString(string: "Remove Fee", font: Font.regular(17.0), textColor: interfaceState.theme.chat.inputPanel.panelControlAccentColor)
92+
self.removeTextNode.attributedText = NSAttributedString(string: interfaceState.strings.Chat_PaidMessageFee_RemoveFee, font: Font.regular(17.0), textColor: interfaceState.theme.chat.inputPanel.panelControlAccentColor)
9493
}
9594

9695
let paidMessageStars = interfaceState.contactStatus?.peerStatusSettings?.paidMessageStars?.value ?? 0
9796

9897
if let peer = interfaceState.renderedPeer?.peer.flatMap(EnginePeer.init) {
99-
let attributedText = NSMutableAttributedString(string: "\(peer.compactDisplayTitle) must pay ⭐️\(paidMessageStars) for each message to you.", font: Font.regular(12.0), textColor: interfaceState.theme.rootController.navigationBar.secondaryTextColor)
98+
let attributedText = NSMutableAttributedString(string: interfaceState.strings.Chat_PaidMessageFee_Text(peer.compactDisplayTitle, "⭐️\(paidMessageStars)").string, font: Font.regular(12.0), textColor: interfaceState.theme.rootController.navigationBar.secondaryTextColor)
10099
let range = (attributedText.string as NSString).range(of: "⭐️")
101100
if range.location != NSNotFound {
102101
attributedText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: range)

0 commit comments

Comments
 (0)