Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Text VPN Tunnel localization is added to string structs
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel committed Apr 26, 2023
1 parent a668f0b commit be935aa
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
25 changes: 25 additions & 0 deletions Sources/BraveStrings/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Sources/BraveVPN/BraveVPN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions Sources/BraveVPN/BraveVPNPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ 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
$0.play()
}

let popup = AlertPopupView(imageView: animation,
title: Strings.VPN.regionSwitchSuccessPopupText, message: "",
title: text, message: "",
titleWeight: .semibold, titleSize: 18,
dismissHandler: { true })

Expand Down
14 changes: 6 additions & 8 deletions Sources/BraveVPN/BraveVPNProtocolPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BraveVPN/BraveVPNRegionPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit be935aa

Please sign in to comment.