diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2021-07-21 12:23:57 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2021-07-21 12:23:57 +0200 |
| commit | 6ca71f1581347d89138722e8b02624731cdab42b (patch) | |
| tree | be7652d33afed25832c3791841e9b00c93d832b1 | |
| parent | ebd44f96e9d09fb36a134b4e6baa6a7f21532268 (diff) | |
| parent | a33a0224fb1104016917f132ce68ed15224a7404 (diff) | |
| download | mullvadvpn-6ca71f1581347d89138722e8b02624731cdab42b.tar.xz mullvadvpn-6ca71f1581347d89138722e8b02624731cdab42b.zip | |
Merge branch 'localize-login'
| -rw-r--r-- | ios/MullvadVPN.xcodeproj/project.pbxproj | 14 | ||||
| -rw-r--r-- | ios/MullvadVPN/LoginContentView.swift | 14 | ||||
| -rw-r--r-- | ios/MullvadVPN/LoginViewController.swift | 72 | ||||
| -rw-r--r-- | ios/MullvadVPN/en.lproj/Login.strings | 44 |
4 files changed, 126 insertions, 18 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index 2a05e00c70..c6e0abe0bf 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -223,6 +223,7 @@ 58F3C0A624A50157003E76BE /* relays.json in Resources */ = {isa = PBXBuildFile; fileRef = 58F3C0A524A50155003E76BE /* relays.json */; }; 58F3C0A724A50C02003E76BE /* relays.json in Resources */ = {isa = PBXBuildFile; fileRef = 58F3C0A524A50155003E76BE /* relays.json */; }; 58F558DD2695B85E00F630D0 /* Consent.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F558DB2695B85E00F630D0 /* Consent.strings */; }; + 58F558E02695BD3E00F630D0 /* Login.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F558DE2695BD3E00F630D0 /* Login.strings */; }; 58F558E32695D1D800F630D0 /* Preferences.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F558E12695D1D800F630D0 /* Preferences.strings */; }; 58F5590E2697002100F630D0 /* Main.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F559052697002000F630D0 /* Main.strings */; }; 58F5590F2697002100F630D0 /* ConnectionPanel.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F559072697002100F630D0 /* ConnectionPanel.strings */; }; @@ -443,6 +444,7 @@ 58F3C0A3249CB069003E76BE /* HeaderBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderBarView.swift; sourceTree = "<group>"; }; 58F3C0A524A50155003E76BE /* relays.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = relays.json; sourceTree = "<group>"; }; 58F558DC2695B85E00F630D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Consent.strings; sourceTree = "<group>"; }; + 58F558DF2695BD3E00F630D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Login.strings; sourceTree = "<group>"; }; 58F558E22695D1D800F630D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = "<group>"; }; 58F559062697002000F630D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = "<group>"; }; 58F559082697002100F630D0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ConnectionPanel.strings; sourceTree = "<group>"; }; @@ -555,9 +557,10 @@ 58F559072697002100F630D0 /* ConnectionPanel.strings */, 58F558DB2695B85E00F630D0 /* Consent.strings */, 587B7543266922BF00DEF7E9 /* Localizable.strings */, + 58F558DE2695BD3E00F630D0 /* Login.strings */, 58F559052697002000F630D0 /* Main.strings */, - 582CFEE8269463B80072883A /* Settings.strings */, 58F558E12695D1D800F630D0 /* Preferences.strings */, + 582CFEE8269463B80072883A /* Settings.strings */, 58F61F4D2692F21C00DCFC2B /* WireguardKeys.strings */, ); name = Localizations; @@ -968,6 +971,7 @@ 58727283265D173C00F315B2 /* LaunchScreen.storyboard in Resources */, 586ADD4723FC13F400CE9E87 /* countries.geo.json in Resources */, 58F5590F2697002100F630D0 /* ConnectionPanel.strings in Resources */, + 58F558E02695BD3E00F630D0 /* Login.strings in Resources */, 58CE5E6B224146210008646E /* Assets.xcassets in Resources */, 5883A09E266A5AF7003EFFCB /* Localizable.strings in Resources */, 58F558E32695D1D800F630D0 /* Preferences.strings in Resources */, @@ -1313,6 +1317,14 @@ name = Consent.strings; sourceTree = "<group>"; }; + 58F558DE2695BD3E00F630D0 /* Login.strings */ = { + isa = PBXVariantGroup; + children = ( + 58F558DF2695BD3E00F630D0 /* en */, + ); + name = Login.strings; + sourceTree = "<group>"; + }; 58F558E12695D1D800F630D0 /* Preferences.strings */ = { isa = PBXVariantGroup; children = ( diff --git a/ios/MullvadVPN/LoginContentView.swift b/ios/MullvadVPN/LoginContentView.swift index ad91eab558..7d12eee025 100644 --- a/ios/MullvadVPN/LoginContentView.swift +++ b/ios/MullvadVPN/LoginContentView.swift @@ -12,7 +12,7 @@ class LoginContentView: UIView { private var keyboardResponder: AutomaticKeyboardResponder? - lazy var titleLabel: UILabel = { + let titleLabel: UILabel = { let textLabel = UILabel() textLabel.font = UIFont.systemFont(ofSize: 32) textLabel.textColor = .white @@ -68,14 +68,22 @@ class LoginContentView: UIView { textLabel.font = UIFont.systemFont(ofSize: 17) textLabel.textColor = UIColor.white.withAlphaComponent(0.6) textLabel.translatesAutoresizingMaskIntoConstraints = false - textLabel.text = NSLocalizedString("Don't have an account number?", comment: "") + textLabel.text = NSLocalizedString( + "CREATE_BUTTON_HEADER_LABEL", + tableName: "Login", + comment: "" + ) return textLabel }() let createAccountButton: AppButton = { let button = AppButton(style: .default) button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle(NSLocalizedString("Create account", comment: ""), for: .normal) + button.setTitle(NSLocalizedString( + "CREATE_ACCOUNT_BUTTON_LABEL", + tableName: "Login", + comment: "" + ), for: .normal) return button }() diff --git a/ios/MullvadVPN/LoginViewController.swift b/ios/MullvadVPN/LoginViewController.swift index 6c4bd2b920..ef5ce6a83c 100644 --- a/ios/MullvadVPN/LoginViewController.swift +++ b/ios/MullvadVPN/LoginViewController.swift @@ -39,7 +39,16 @@ class LoginViewController: UIViewController, RootContainment { }() private lazy var accountInputAccessoryLoginButton: UIBarButtonItem = { - let barButtonItem = UIBarButtonItem(title: NSLocalizedString("Log in", comment: ""), style: .done, target: self, action: #selector(doLogin)) + let barButtonItem = UIBarButtonItem( + title: NSLocalizedString( + "LOGIN_ACCESSORY_TOOLBAR_BUTTON_TITLE", + tableName: "Login", + comment: "Title for 'Log in' button displayed in toolbar above keyboard on iPhone." + ), + style: .done, + target: self, + action: #selector(doLogin) + ) barButtonItem.accessibilityIdentifier = "LoginBarButtonItem" return barButtonItem @@ -270,33 +279,51 @@ private extension LoginState { var localizedTitle: String { switch self { case .default: - return NSLocalizedString("Login", comment: "") + return NSLocalizedString("HEADING_TITLE_DEFAULT", tableName: "Login", comment: "Default login prompt heading.") case .authenticating: - return NSLocalizedString("Logging in...", comment: "") + return NSLocalizedString("HEADING_TITLE_AUTHENTICATING", tableName: "Login", comment: "Heading displayed during authentication.") case .failure: - return NSLocalizedString("Login failed", comment: "") + return NSLocalizedString("HEADING_TITLE_FAILURE", tableName: "Login", comment: "Heading displayed upon failure to authenticate.") case .success: - return NSLocalizedString("Logged in", comment: "") + return NSLocalizedString("HEADING_TITLE_SUCCESS", tableName: "Login", comment: "Heading displayed upon successful authentication.") } } var localizedMessage: String { switch self { case .default: - return NSLocalizedString("Enter your account number", comment: "") + return NSLocalizedString( + "SUBHEAD_TITLE_DEFAULT", + tableName: "Login", + comment: "Default login prompt subhead." + ) case .authenticating(let method): switch method { case .existingAccount: - return NSLocalizedString("Checking account number", comment: "") + return NSLocalizedString( + "SUBHEAD_TITLE_AUTHENTICATING", + tableName: "Login", + comment: "Subhead displayed during authentication." + ) case .newAccount: - return NSLocalizedString("Creating new account", comment: "") + return NSLocalizedString( + "SUBHEAD_TITLE_CREATING_ACCOUNT", + tableName: "Login", + comment: "Subhead displayed when creating new account." + ) } case .failure(let error): + let localizedUnknownInternalError = NSLocalizedString( + "SUBHEAD_TITLE_INTERNAL_ERROR", + tableName: "Login", + comment: "Subhead displayed in the event of internal error." + ) + switch error { case .createAccount(let rpcError), .verifyAccount(let rpcError): return rpcError.errorChainDescription ?? "" @@ -305,12 +332,21 @@ private extension LoginState { switch pushError { case .network(let urlError): return String( - format: NSLocalizedString("Network error: %@", comment: ""), + format: NSLocalizedString( + "SUBHEAD_TITLE_NETWORK_ERROR_FORMAT", + tableName: "Login", + value: "Network error: %@", + comment: "Subhead displayed in the event of network error. Use %@ placeholder to place localized text describing network failure." + ), urlError.localizedDescription ) case .server(let serverError): - var message = serverError.errorDescription ?? NSLocalizedString("Unknown server error.", comment: "") + var message = serverError.errorDescription ?? NSLocalizedString( + "SUBHEAD_TITLE_UNKNOWN_SERVER_ERROR", + tableName: "Login", + comment: "Subhead displayed in the event of unknown server error." + ) if let recoverySuggestion = serverError.recoverySuggestion { message.append("\n\(recoverySuggestion)") @@ -319,19 +355,27 @@ private extension LoginState { return message case .encodePayload, .decodeErrorResponse, .decodeSuccessResponse: - return NSLocalizedString("Internal error", comment: "") + return localizedUnknownInternalError } } else { - return NSLocalizedString("Internal error", comment: "") + return localizedUnknownInternalError } } case .success(let method): switch method { case .existingAccount: - return NSLocalizedString("Correct account number", comment: "") + return NSLocalizedString( + "SUBHEAD_TITLE_SUCCESS", + tableName: "Login", + comment: "Subhead displayed upon successful authentication using existing account token." + ) case .newAccount: - return NSLocalizedString("Account created", comment: "") + return NSLocalizedString( + "SUBHEAD_TITLE_CREATED_ACCOUNT", + tableName: "Login", + comment: "Subhead displayed upon successful authentication with newly created account token." + ) } } } diff --git a/ios/MullvadVPN/en.lproj/Login.strings b/ios/MullvadVPN/en.lproj/Login.strings new file mode 100644 index 0000000000..ffb89248e0 --- /dev/null +++ b/ios/MullvadVPN/en.lproj/Login.strings @@ -0,0 +1,44 @@ +/* No comment provided by engineer. */ +"CREATE_ACCOUNT_BUTTON_LABEL" = "Create account"; + +/* No comment provided by engineer. */ +"CREATE_BUTTON_HEADER_LABEL" = "Don't have an account number?"; + +/* Heading displayed during authentication. */ +"HEADING_TITLE_AUTHENTICATING" = "Logging in..."; + +/* Default login prompt heading. */ +"HEADING_TITLE_DEFAULT" = "Login"; + +/* Heading displayed upon failure to authenticate. */ +"HEADING_TITLE_FAILURE" = "Login failed"; + +/* Heading displayed upon successful authentication. */ +"HEADING_TITLE_SUCCESS" = "Logged in"; + +/* Title for 'Log in' button displayed in toolbar above keyboard on iPhone. */ +"LOGIN_ACCESSORY_TOOLBAR_BUTTON_TITLE" = "Log in"; + +/* Subhead displayed during authentication. */ +"SUBHEAD_TITLE_AUTHENTICATING" = "Checking account number"; + +/* Subhead displayed upon successful authentication with newly created account token. */ +"SUBHEAD_TITLE_CREATED_ACCOUNT" = "Account created"; + +/* Subhead displayed when creating new account. */ +"SUBHEAD_TITLE_CREATING_ACCOUNT" = "Creating new account"; + +/* Default login prompt subhead. */ +"SUBHEAD_TITLE_DEFAULT" = "Enter your account number"; + +/* Subhead displayed in the event of internal error. */ +"SUBHEAD_TITLE_INTERNAL_ERROR" = "Internal error"; + +/* Subhead displayed in the event of network error. Use %@ placeholder to place localized text describing network failure. */ +"SUBHEAD_TITLE_NETWORK_ERROR_FORMAT" = "Network error: %@"; + +/* Subhead displayed upon successful authentication using existing account token. */ +"SUBHEAD_TITLE_SUCCESS" = "Correct account number"; + +/* Subhead displayed in the event of unknown server error. */ +"SUBHEAD_TITLE_UNKNOWN_SERVER_ERROR" = "Unknown server error"; |
