From be935aad877b030a0d6d0ebe73062df42a0412a8 Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Tue, 25 Apr 2023 17:10:14 -0400 Subject: [PATCH] Text VPN Tunnel localization is added to string structs --- Sources/BraveStrings/BraveStrings.swift | 25 +++++++++++++++++++ Sources/BraveVPN/BraveVPN.swift | 2 +- .../BraveVPNPickerViewController.swift | 4 +-- ...BraveVPNProtocolPickerViewController.swift | 14 +++++------ .../BraveVPNRegionPickerViewController.swift | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Sources/BraveStrings/BraveStrings.swift b/Sources/BraveStrings/BraveStrings.swift index de2c3a76a96..ef52e0e8a51 100644 --- a/Sources/BraveStrings/BraveStrings.swift +++ b/Sources/BraveStrings/BraveStrings.swift @@ -2869,10 +2869,35 @@ extension Strings { value: "Failed to switch servers, please try again later.", comment: "Message for error when we fail to switch vpn server for the user") + public static let protocolPickerTitle = + NSLocalizedString("vpn.protocolPickerTitle", tableName: "BraveShared", bundle: .module, + value: "Transport Protocol", + comment: "Title for vpn tunnel protocol screen") + + public static let protocolPickerDescription = + NSLocalizedString("vpn.protocolPickerDescription", tableName: "BraveShared", bundle: .module, + value: "Please select your preferred transport protocol. Once switched your existing VPN credentials will be cleared and you will be reconnected if a VPN connection is currently established.", + comment: "Description of vpn tunnel protocol") + public static let regionSwitchSuccessPopupText = NSLocalizedString("vpn.regionSwitchSuccessPopupText", tableName: "BraveShared", bundle: .module, value: "VPN region changed.", comment: "Message that we show after successfully changing vpn region.") + + public static let protocolPickerErrorTitle = + NSLocalizedString("vpn.protocolPickerErrorTitle", tableName: "BraveShared", bundle: .module, + value: "Server Error", + comment: "Title for error when we fail to switch tunnel protocol for the user") + + public static let protocolPickerErrorMessage = + NSLocalizedString("vpn.protocolPickerErrorMessage", tableName: "BraveShared", bundle: .module, + value: "Failed to switch tunnel protocol, please try again later.", + comment: "Message for error when we fail to switch tunnel protocol for the user") + + public static let protocolSwitchSuccessPopupText = + NSLocalizedString("vpn.protocolSwitchSuccessPopupText", tableName: "BraveShared", bundle: .module, + value: "VPN Tunnel Protocol changed.", + comment: "Message that we show after successfully changing tunnel protocol.") public static let settingsFailedToFetchServerList = NSLocalizedString("vpn.settingsFailedToFetchServerList", tableName: "BraveShared", bundle: .module, diff --git a/Sources/BraveVPN/BraveVPN.swift b/Sources/BraveVPN/BraveVPN.swift index e9f796903b1..9b4f6dd55b5 100644 --- a/Sources/BraveVPN/BraveVPN.swift +++ b/Sources/BraveVPN/BraveVPN.swift @@ -282,7 +282,7 @@ public class BraveVPN { // Setting User preferred Transport Protocol to WireGuard // In order to easily fetch and change in settings later GRDTransportProtocol.setUserPreferred(.wireGuard) - + // New user or no credentials and have to remake them. helper.configureFirstTimeUser( for: GRDTransportProtocol.getUserPreferredTransportProtocol(), diff --git a/Sources/BraveVPN/BraveVPNPickerViewController.swift b/Sources/BraveVPN/BraveVPNPickerViewController.swift index 8ab29b2828c..bb33a599359 100644 --- a/Sources/BraveVPN/BraveVPNPickerViewController.swift +++ b/Sources/BraveVPN/BraveVPNPickerViewController.swift @@ -75,7 +75,7 @@ class BraveVPNPickerViewController: UIViewController { @objc func vpnConfigChanged(notification: NSNotification) { } - func showSuccessAlert() { + func showSuccessAlert(text: String) { let animation = AnimationView(name: "vpncheckmark", bundle: .module).then { $0.bounds = CGRect(x: 0, y: 0, width: 300, height: 200) $0.contentMode = .scaleAspectFill @@ -83,7 +83,7 @@ class BraveVPNPickerViewController: UIViewController { } let popup = AlertPopupView(imageView: animation, - title: Strings.VPN.regionSwitchSuccessPopupText, message: "", + title: text, message: "", titleWeight: .semibold, titleSize: 18, dismissHandler: { true }) diff --git a/Sources/BraveVPN/BraveVPNProtocolPickerViewController.swift b/Sources/BraveVPN/BraveVPNProtocolPickerViewController.swift index 4946d7fb153..a0c8872727c 100644 --- a/Sources/BraveVPN/BraveVPNProtocolPickerViewController.swift +++ b/Sources/BraveVPN/BraveVPNProtocolPickerViewController.swift @@ -28,14 +28,12 @@ class BraveVPNProtocolPickerViewController: BraveVPNPickerViewController { required init?(coder: NSCoder) { fatalError() } override func viewDidLoad() { - title = "Transport Protocol" + title = Strings.VPN.protocolPickerTitle tableView.delegate = self tableView.dataSource = self super.viewDidLoad() - - print("Transport Protocol \(GRDTransportProtocol.getUserPreferredTransportProtocol())") } override func vpnConfigChanged(notification: NSNotification) { @@ -58,7 +56,7 @@ extension BraveVPNProtocolPickerViewController: UITableViewDelegate, UITableView } func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { - return "Please select your preferred transport protocol. Once switched your existing VPN credentials will be cleared and you will be reconnected if a VPN connection is currently established" + return Strings.VPN.protocolPickerDescription } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { @@ -94,15 +92,15 @@ extension BraveVPNProtocolPickerViewController: UITableViewDelegate, UITableView BraveVPN.changePreferredTransportProtocol(with: tunnelProtocol) { [weak self] success in guard let self else { return } - isLoading = false + self.isLoading = false if success { self.dismiss(animated: true) { - self.showSuccessAlert() + self.showSuccessAlert(text: Strings.VPN.protocolSwitchSuccessPopupText) } } else { - self.showErrorAlert(title: "Error", - message: "Failed to change transport protocol.") + self.showErrorAlert(title: Strings.VPN.protocolPickerErrorTitle, + message: Strings.VPN.protocolPickerErrorMessage) } } diff --git a/Sources/BraveVPN/BraveVPNRegionPickerViewController.swift b/Sources/BraveVPN/BraveVPNRegionPickerViewController.swift index b10da979f93..962853111c5 100644 --- a/Sources/BraveVPN/BraveVPNRegionPickerViewController.swift +++ b/Sources/BraveVPN/BraveVPNRegionPickerViewController.swift @@ -142,7 +142,7 @@ extension BraveVPNRegionPickerViewController: UITableViewDelegate, UITableViewDa if self.vpnRegionChangeSuccess { self.dismiss(animated: true) { - self.showSuccessAlert() + self.showSuccessAlert(text: Strings.VPN.regionSwitchSuccessPopupText) } } else { self.showErrorAlert(title: Strings.VPN.regionPickerErrorTitle,