Skip to content

Commit

Permalink
Added more localized strings from view models.
Browse files Browse the repository at this point in the history
  • Loading branch information
jensutbult committed Apr 24, 2024
1 parent c28bf57 commit cc6ec0b
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 39 deletions.
3 changes: 0 additions & 3 deletions Authenticator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
5156D05F265D3CEF007A94F8 /* TokenRequestViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5156D05E265D3CEF007A94F8 /* TokenRequestViewModel.swift */; };
5180974326DE185100A122C1 /* ResetOATHViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5180974226DE185100A122C1 /* ResetOATHViewModel.swift */; };
51A162862678A1F100C3FA1E /* OATHConfigurationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51A162852678A1F100C3FA1E /* OATHConfigurationController.swift */; };
51AFD4D42716FC78008F2630 /* NFCSettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51AFD4D32716FC78008F2630 /* NFCSettingsController.swift */; };
51AFD4D62716FCDB008F2630 /* ApplicationSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51AFD4D52716FCDB008F2630 /* ApplicationSettingsViewModel.swift */; };
51AFD4D827196AB6008F2630 /* VersionHistory.plist in Resources */ = {isa = PBXBuildFile; fileRef = 51AFD4D727196AB6008F2630 /* VersionHistory.plist */; };
51AFD4DA271D4278008F2630 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51AFD4D9271D4277008F2630 /* QuartzCore.framework */; };
Expand Down Expand Up @@ -778,9 +777,7 @@
5155428326569ADD00B19C59 /* UIControl+Extensions.swift in Sources */,
B452EC1F2A1E4F460045E5D9 /* YubiOtpRowView.swift in Sources */,
A544948F23CE546B003E1E07 /* TutorialPagesViewControllers.swift in Sources */,
51AFD4D42716FC78008F2630 /* NFCSettingsController.swift in Sources */,
B4719B19298AA757006CDAEA /* AuthenticatorApp.swift in Sources */,
51AFD4D42716FC78008F2630 /* NFCSettingsController.swift in Sources */,
51394C5C26D4D460009F366D /* MenuGestureRecognizer.swift in Sources */,
A5588BF9239B0A7F003E4CA5 /* FavoritesStorage.swift in Sources */,
B4B1711827DF8C48002A62DE /* ScanAccountView.swift in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions Authenticator/AuthenticatorApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import SwiftUI
import YubiKit

@main
struct AuthenticatorApp: App {
Expand All @@ -38,6 +39,10 @@ struct AuthenticatorApp: App {
.navigationViewStyle(.stack)
.environmentObject(toastPresenter)
.environmentObject(notificationsViewModel)
.onAppear {
YubiKitExternalLocalization.nfcScanAlertMessage = String(localized: "Scan your YubiKey", comment: "iOS NFC alert scan")
YubiKitExternalLocalization.nfcScanSuccessAlertMessage = String(localized: "Success", comment: "iOS NFC alert default success message")
}
}
}
}
94 changes: 91 additions & 3 deletions Authenticator/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
"About" : {
"comment" : "About view navigation title"
},
"Account deleted" : {
"comment" : "OATH NFC account deleted"
},
"Account name can not be empty" : {
"comment" : "Rename credential alert"
},
"Account not set" : {
"comment" : "Rename credential alert"
},
"Account renamed" : {
"comment" : "OATH NFC account renamed"
},
"Accounts" : {
"comment" : "Navigation title in main view.",
"localizations" : {
Expand Down Expand Up @@ -51,6 +57,9 @@
"and can be used by other applications" : {
"comment" : "PIV extension substring in 'These certificates have been added to this [iPad/iPhone] and can be used by other applications'"
},
"Authentication required" : {
"comment" : "Password Configuration auth required"
},
"Calculate" : {
"comment" : "Menu"
},
Expand Down Expand Up @@ -92,6 +101,9 @@
"Close" : {
"comment" : "View close button"
},
"Code calculated" : {
"comment" : "OATH NFC code calculated"
},
"Code expired" : {
"comment" : "Accessibility label"
},
Expand Down Expand Up @@ -210,6 +222,9 @@
"Dismiss details view" : {
"comment" : "Accessibility hint"
},
"Duplicate accounts!" : {
"comment" : "OATH add credential duplicate accounts error"
},
"Enabled" : {
"comment" : "PIV extension enabled message"
},
Expand Down Expand Up @@ -256,14 +271,20 @@
"Failed to reset YubiKey" : {
"comment" : "Reset YubiKey failure alert title"
},
"Finished reading certificates" : {
"comment" : "PIV extension NFC finished reading certs"
},
"Incorrect password. Re-enter password." : {
"comment" : "Password entry error alert message"
"comment" : "OATH password entry retry"
},
"Insert YubiKey" : {

},
"Insert YubiKey or pull down to activate NFC" : {

},
"Invalid signature" : {
"comment" : "PIV extension NFC invalid signature"
},
"Invalid URI format" : {
"comment" : "Invalid Uri, wrong parameters",
Expand Down Expand Up @@ -298,6 +319,9 @@
}
}
},
"Key is password protected" : {
"comment" : "OATH NFC password protected key"
},
"Licensing" : {
"comment" : "Licensing view navigation title"
},
Expand All @@ -307,6 +331,9 @@
"Never for this YubiKey" : {
"comment" : "Save password alert."
},
"New OTP configuration saved" : {
"comment" : "Settings OTP configuration saved"
},
"No account information found!" : {
"comment" : "Scan QR code no account error message"
},
Expand Down Expand Up @@ -343,12 +370,18 @@
"Notifications disabled" : {
"comment" : "PIV extension notifications alert title"
},
"OATH accounts deleted and OATH application reset to factory defaults." : {
"comment" : "OATH reset confirmation message"
},
"Ok" : {
"comment" : "Password alert"
},
"OK" : {
"comment" : "OK button in error alert."
},
"on this YubiKey" : {
"comment" : "OATH substring in 'There's already an account named [issuer, name] on this YubiKey."
},
"Open iOS Settings app" : {
"comment" : "Scan QR code settings button"
},
Expand Down Expand Up @@ -383,6 +416,15 @@
"Password can not be an empty string" : {
"comment" : "Configuration set password empty password error alert message"
},
"Password has been changed" : {
"comment" : "Password Configuration password changed"
},
"Password has been removed" : {
"comment" : "Password Configuration password removed"
},
"Password has been set" : {
"comment" : "Password Configuration password set"
},
"Period" : {
"comment" : "Add account select period"
},
Expand Down Expand Up @@ -431,6 +473,9 @@
"Read more..." : {
"comment" : "PIV extension read more alert title"
},
"Read YubiKey OTP configuration" : {
"comment" : "Settings OTP configuration read"
},
"Remove and re-insert your YubiKey" : {
"localizations" : {
"fr" : {
Expand Down Expand Up @@ -485,6 +530,9 @@
},
"Scan NFC YubiKey" : {

},
"Scan your YubiKey" : {
"comment" : "iOS NFC alert scan"
},
"Search" : {

Expand All @@ -495,11 +543,17 @@
"Settings" : {
"comment" : "PIV extension settings alert title"
},
"Signing failed" : {
"comment" : "PIV extension signing failed error message"
},
"Smart card extension" : {
"comment" : "PIV extension info alert title"
},
"Smart card extension is only available on iOS 14.5 and forward." : {
"comment" : "PIV extension version error"
},
"Something went wrong" : {

},
"Something went wrong and key doesn't respond" : {
"comment" : "No response",
Expand Down Expand Up @@ -538,7 +592,16 @@
}
},
"Success" : {
"comment" : "Clear passwords confirmation alert title"
"comment" : "Clear passwords confirmation alert title\niOS NFC alert default success message"
},
"Success!\nHint: swipe down to dismiss" : {
"comment" : "iOS NFC alert success with hint"
},
"Successfully read" : {
"comment" : "iOS NFC alert successfully read"
},
"Successfully signed data" : {
"comment" : "PIV extension NFC successfully signed data"
},
"The key doesn't respond" : {
"comment" : "Timeout issue",
Expand All @@ -560,9 +623,18 @@
"The passwords do not match" : {
"comment" : "Configuration set password not matching error alert message"
},
"The private key on the YubiKey does not match the certificate or there is no private key stored on the YubiKey." : {
"comment" : "PIV extension NFC invalid signature no private key"
},
"The private key on the YubiKey does not match the certificate." : {
"comment" : "PIV extension invalid signature message"
},
"The smart card extension requires notifications to be enabled for Yubico Authenticator. Enable it in the iOS Settings." : {
"comment" : "PIV extensions notifications alert message"
},
"There's already an account named" : {
"comment" : "OATH substring in 'There's already an account named [issuer, name] on this YubiKey."
},
"These certificates have been added to this" : {
"comment" : "PIV extension substring in 'These certificates have been added to this [iPad/iPhone] and can be used by other applications'"
},
Expand Down Expand Up @@ -639,7 +711,7 @@
}
},
"To prevent unauthorized access this YubiKey is protected with a password." : {
"comment" : "Password entry alert message"
"comment" : "OATH password entry enter password"
},
"To scan a QR code you need to enable camera permissions for the Authenticator app." : {
"comment" : "Scan QR code camera error message"
Expand Down Expand Up @@ -669,6 +741,9 @@
"Unpin" : {
"comment" : "Menu"
},
"Use your PUK code to reset PIN." : {
"comment" : "PIV extension pin blocked text"
},
"Version history" : {
"comment" : "Version history navigation title"
},
Expand Down Expand Up @@ -697,9 +772,18 @@
"Would you like to save this password for YubiKey for next usage in this application?" : {
"comment" : "Password entry save password title"
},
"Wrong password" : {
"comment" : "Password Configuration wrong password"
},
"Wrong PIN code" : {
"comment" : "PIV extension wrong pin"
},
"You can remove saved password in Settings." : {
"comment" : "Password entry save password message"
},
"Your PIN has ben blocked" : {
"comment" : "PIV extension pin blocked title"
},
"Yubico OTP" : {
"localizations" : {
"fr" : {
Expand All @@ -717,6 +801,7 @@
}
},
"Yubico OTP enabled" : {
"comment" : "OATH otp enabled error message",
"localizations" : {
"fr" : {
"stringUnit" : {
Expand Down Expand Up @@ -747,6 +832,9 @@
}
}
}
},
"YubiKey information read" : {
"comment" : "YubiKey info NFC read"
}
},
"version" : "1.0"
Expand Down
20 changes: 10 additions & 10 deletions Authenticator/Model/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class MainViewModel: ObservableObject {
account.update(otp: otp)
}

session.endNFC(message: "Code calculated")
session.endNFC(message: String(localized: "Code calculated", comment: "OATH NFC code calculated"))
} catch {
handle(error: error, retry: { Task { await self.updateAccount(account) }})
}
Expand Down Expand Up @@ -210,7 +210,7 @@ class MainViewModel: ObservableObject {
}

self.accountsLoaded = true
let message = SettingsConfig.showNFCSwipeHint ? "Success!\nHint: swipe down to dismiss" : "Successfully read"
let message = SettingsConfig.showNFCSwipeHint ? String(localized: "Success!\nHint: swipe down to dismiss", comment: "iOS NFC alert success with hint") : String(localized: "Successfully read", comment: "iOS NFC alert successfully read")
useSession.endNFC(message: message)
} catch {
handle(error: error, retry: { Task { await self.updateAccounts() }})
Expand All @@ -233,7 +233,7 @@ class MainViewModel: ObservableObject {
let session = try await OATHSessionHandler.shared.nfcSession()
await updateAccounts(using: session)
} catch {
YubiKitManager.shared.stopNFCConnection(withErrorMessage: "Something went wrong")
YubiKitManager.shared.stopNFCConnection(withErrorMessage: String(localized: "Something went wrong"))
self.sessionError = error
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ class MainViewModel: ObservableObject {
account.updateTitles()
account.isPinned = wasPinned
await updateAccounts(using: session)
YubiKitManager.shared.stopNFCConnection(withMessage: "Account renamed")
YubiKitManager.shared.stopNFCConnection(withMessage: String(localized: "Account renamed", comment: "OATH NFC account renamed"))
completion()
} catch {
handle(error: error, retry: { self.renameAccount(account, issuer: issuer, accountName: accountName, completion: completion) })
Expand All @@ -281,7 +281,7 @@ class MainViewModel: ObservableObject {
accounts.removeAll { $0.accountId == account.accountId }
pinnedAccounts.removeAll { $0.accountId == account.accountId }
otherAccounts.removeAll { $0.accountId == account.accountId }
session.endNFC(message: "Account deleted")
session.endNFC(message: String(localized: "Account deleted", comment: "OATH NFC account deleted"))
completion()
} catch {
handle(error: error, retry: { self.deleteAccount(account, completion: completion) })
Expand All @@ -291,8 +291,8 @@ class MainViewModel: ObservableObject {

func collectPasswordAndUnlock(isRetry: Bool = false, completion: @escaping (Error?) -> Void) {
DispatchQueue.main.async {
YubiKitManager.shared.stopNFCConnection(withErrorMessage: "Key is password protected")
self.passwordEntryMessage = isRetry ? "Incorrect password. Re-enter password." : "To prevent unauthorized access this YubiKey is protected with a password."
YubiKitManager.shared.stopNFCConnection(withErrorMessage: String(localized: "Key is password protected", comment: "OATH NFC password protected key"))
self.passwordEntryMessage = isRetry ? String(localized: "Incorrect password. Re-enter password.", comment: "OATH password entry retry") : String(localized: "To prevent unauthorized access this YubiKey is protected with a password.", comment: "OATH password entry enter password")
self.presentPasswordEntry = true
self.passwordCancellable = self.password.sink { password in
if let password {
Expand Down Expand Up @@ -324,7 +324,7 @@ class MainViewModel: ObservableObject {
} catch {
self.collectPasswordAndUnlock() { error in
if let error {
YubiKitManager.shared.stopNFCConnection(withErrorMessage: "Something went wrong")
YubiKitManager.shared.stopNFCConnection(withErrorMessage: String(localized: "Something went wrong"))
self.handle(error: error, retry: retry)
} else {
retry?()
Expand All @@ -335,7 +335,7 @@ class MainViewModel: ObservableObject {
} else {
self.collectPasswordAndUnlock() { error in
if let error {
YubiKitManager.shared.stopNFCConnection(withErrorMessage: "Something went wrong")
YubiKitManager.shared.stopNFCConnection(withErrorMessage: String(localized: "Something went wrong"))
self.handle(error: error, retry: retry)
} else {
retry?()
Expand All @@ -346,7 +346,7 @@ class MainViewModel: ObservableObject {
} else if let oathError = error as? YKFOATHError, oathError.code == YKFOATHErrorCode.wrongPassword.rawValue {
collectPasswordAndUnlock(isRetry: true) { error in
if let error {
YubiKitManager.shared.stopNFCConnection(withErrorMessage: "Something went wrong")
YubiKitManager.shared.stopNFCConnection(withErrorMessage: String(localized: "Something went wrong"))
self.handle(error: error, retry: retry)
} else {
retry?()
Expand Down
4 changes: 2 additions & 2 deletions Authenticator/Model/ManagementViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ManagementViewModel {
return
}
session.getDeviceInfo { deviceInfo, error in
YubiKitManager.shared.stopNFCConnection(withMessage: "Read YubiKey OTP configuration")
YubiKitManager.shared.stopNFCConnection(withMessage: String(localized: "Read YubiKey OTP configuration", comment: "Settings OTP configuration read"))
guard let deviceInfo = deviceInfo else { completion(.failure(error!)); return }
guard let configuration = deviceInfo.configuration else {
completion(.failure(ManagementViewModelError.unknownError))
Expand Down Expand Up @@ -103,7 +103,7 @@ class ManagementViewModel {
completion(errorToPassOn)
return
} else {
YubiKitManager.shared.stopNFCConnection(withMessage: "New OTP configuration saved")
YubiKitManager.shared.stopNFCConnection(withMessage: String(localized: "New OTP configuration saved", comment: "Settings OTP configuration saved"))
}
completion(nil)
}
Expand Down
Loading

0 comments on commit cc6ec0b

Please sign in to comment.