Skip to content

Commit 7ec2723

Browse files
committed
Merge branch 'jens/localization'
2 parents 9e5d0ad + 9a4525e commit 7ec2723

38 files changed

+27
-27
lines changed

Authenticator/UI/AccountDetailsView.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct AccountDetailsView: View {
110110
}
111111
}
112112
.accessibilityElement()
113-
.accessibilityHint("Dismiss details view")
113+
.accessibilityHint(String(localized: "Dismiss details view", comment: "Accessibility hint"))
114114
.accessibilityAction {
115115
self.data = nil
116116
}
@@ -148,7 +148,7 @@ struct AccountDetailsView: View {
148148
account.calculate()
149149
}
150150
.accessibilityAddTraits(.isButton)
151-
.accessibilityLabel(account.state == .expired ? "Code expired" : account.formattedCode ?? "Code not calculated")
151+
.accessibilityLabel(account.state == .expired ? String(localized: "Code expired", comment: "Accessibility label") : account.formattedCode ?? String(localized: "Code not calculated", comment: "Accessibility label"))
152152

153153
ZStack {
154154
if let otp = data.account.formattedCode {
@@ -212,20 +212,20 @@ struct AccountDetailsView: View {
212212
}
213213

214214
DetachedMenu(menuActions: [
215-
DetachedMenuAction(style: .default, isEnabled: account.enableRefresh, title: "Calculate", systemImage: "arrow.clockwise", action: {
215+
DetachedMenuAction(style: .default, isEnabled: account.enableRefresh, title: String(localized: "Calculate", comment: "Menu"), systemImage: "arrow.clockwise", action: {
216216
self.account.calculate()
217217
}),
218-
DetachedMenuAction(style: .default, isEnabled: account.state != .expired && account.otp != nil, title: "Copy", systemImage: "square.and.arrow.up", action: {
218+
DetachedMenuAction(style: .default, isEnabled: account.state != .expired && account.otp != nil, title: String(localized: "Copy", comment: "Menu"), systemImage: "square.and.arrow.up", action: {
219219
guard let otp = account.otp?.code else { return }
220220
toastPresenter.copyToClipboard(otp)
221221
}),
222-
DetachedMenuAction(style: .default, isEnabled: true, title: account.isPinned ? "Unpin" : "Pin", systemImage: "pin", action: {
222+
DetachedMenuAction(style: .default, isEnabled: true, title: account.isPinned ? String(localized: "Unpin", comment: "Menu") : String(localized: "Pin", comment: "Menu"), systemImage: "pin", action: {
223223
account.isPinned.toggle()
224224
}),
225-
account.keyVersion >= YKFVersion(string: "5.3.0") ? DetachedMenuAction(style: .default, isEnabled: true, title: "Rename", systemImage: "square.and.pencil", action: {
225+
account.keyVersion >= YKFVersion(string: "5.3.0") ? DetachedMenuAction(style: .default, isEnabled: true, title: String(localized: "Rename", comment: "Menu"), systemImage: "square.and.pencil", action: {
226226
showEditing.toggle()
227227
}) : nil,
228-
DetachedMenuAction(style: .destructive, isEnabled: true, title: "Delete", systemImage: "trash", action: {
228+
DetachedMenuAction(style: .destructive, isEnabled: true, title: String(localized: "Delete", comment: "Menu"), systemImage: "trash", action: {
229229
showDeleteConfirmation = true
230230
})
231231
].compactMap { $0 } )

Authenticator/UI/AccountRowView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct AccountRowView: View {
126126
.stroke(pillColor, lineWidth: 1)
127127
}
128128
.accessibilityElement()
129-
.accessibilityLabel(account.state == .expired ? "Code expired" : account.formattedCode ?? "Code not calculated")
129+
.accessibilityLabel(account.state == .expired ? String(localized: "Code expired", comment: "Accessibility label") : account.formattedCode ?? String(localized: "Code not calculated", comment: "Accessibility label"))
130130
.opacity(pillOpacity)
131131
.scaleEffect(pillScaling)
132132
}

Authenticator/UI/ErrorAlertView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import SwiftUI
1818

1919
extension View {
20-
func errorAlert(error: Binding<Error?>, buttonTitle: String = "OK", handler: (() -> Void)? = nil) -> some View {
20+
func errorAlert(error: Binding<Error?>, buttonTitle: String = String(localized: "OK", comment:"OK button in error alert."), handler: (() -> Void)? = nil) -> some View {
2121
let localizedAlertError = LocalizedAlertError(error: error.wrappedValue)
2222
return alert(isPresented: .constant(localizedAlertError != nil), error: localizedAlertError) { _ in
2323
Button(buttonTitle) {

Authenticator/UI/ListStatusView.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ struct ListStatusView: View {
4646
.frame(height: height - 100)
4747
.listRowSeparator(.hidden)
4848
.sheet(isPresented: $showWhatsNew) {
49-
VersionHistoryView(title: "What's new in\nYubico Authenticator")
49+
VersionHistoryView(title: String(localized: "What's new in\nYubico Authenticator", comment: "Version history title"))
5050
}
5151
}
5252
}
5353

5454
struct WhatsNewView: View {
5555

5656
var text: AttributedString {
57-
var see = AttributedString("See ")
57+
var see = AttributedString(localized: "See ", comment: "Substring in \"See what's new in this version\"")
5858
see.foregroundColor = .secondaryLabel
59-
var whatsNew = AttributedString("what's new")
59+
var whatsNew = AttributedString(localized: "what's new", comment: "Substring in \"See what's new in this version\"")
6060
whatsNew.foregroundColor = Color(.yubiBlue)
61-
var inThisVersion = AttributedString(" in this version")
61+
var inThisVersion = AttributedString(localized: " in this version", comment: "Substring in \"See what's new in this version\"")
6262
inThisVersion.foregroundColor = .secondaryLabel
6363
return see + whatsNew + inThisVersion
6464
}

Authenticator/UI/MainView.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ struct MainView: View {
3838

3939
var insertYubiKeyMessage = {
4040
if YubiKitDeviceCapabilities.supportsISO7816NFCTags {
41-
"Insert YubiKey \(!UIAccessibility.isVoiceOverRunning ? "or pull down to activate NFC" : "or scan a NFC YubiKey")"
41+
String(localized: "Insert YubiKey") + "\(!UIAccessibility.isVoiceOverRunning ? String(localized: "or pull down to activate NFC") : String(localized: "or scan a NFC YubiKey"))"
4242
} else {
43-
"Insert YubiKey"
43+
String(localized: "Insert YubiKey")
4444
}
4545
}()
4646

@@ -61,7 +61,7 @@ struct MainView: View {
6161
AccountRowView(account: account, showAccountDetails: $showAccountDetails)
6262
}
6363
} else {
64-
ListStatusView(image: Image(systemName: "person.crop.circle.badge.questionmark"), message: "No matching accounts on YubiKey", height: reader.size.height)
64+
ListStatusView(image: Image(systemName: "person.crop.circle.badge.questionmark"), message: String(localized: "No matching accounts on YubiKey"), height: reader.size.height)
6565
}
6666
} else if model.pinnedAccounts.count > 0 {
6767
Section(header: Text("Pinned").frame(maxWidth: .infinity, alignment: .leading).font(.title3.bold()).foregroundColor(Color("ListSectionHeaderColor"))) {
@@ -87,12 +87,12 @@ struct MainView: View {
8787
AccountRowView(account: account, showAccountDetails: $showAccountDetails)
8888
}
8989
} else {
90-
ListStatusView(image: Image(systemName: "person.crop.circle"), message: "No accounts on YubiKey", height: reader.size.height)
90+
ListStatusView(image: Image(systemName: "person.crop.circle"), message: String(localized: "No accounts on YubiKey"), height: reader.size.height)
9191
}
9292
}
9393
}
9494
.accessibilityHidden(showAccountDetails != nil)
95-
.searchable(text: $searchText, prompt: "Search")
95+
.searchable(text: $searchText, prompt: String(localized: "Search"))
9696
.autocorrectionDisabled(true)
9797
.keyboardType(.asciiCapable)
9898
.listStyle(.inset)
@@ -138,7 +138,7 @@ struct MainView: View {
138138
}
139139
}
140140
}
141-
.navigationTitle(model.accountsLoaded ? "Accounts" : "")
141+
.navigationTitle(model.accountsLoaded ? String(localized: "Accounts", comment: "Navigation title in main view.") : "")
142142
}
143143
.accessibilityHidden(showAccountDetails != nil)
144144
.overlay {
@@ -159,24 +159,24 @@ struct MainView: View {
159159
DisableOTPView()
160160
}
161161

162-
.alert("Enter password", isPresented: $model.presentPasswordEntry) {
163-
SecureField("Password", text: $password)
164-
Button("Cancel", role: .cancel) { password = "" }
165-
Button("Ok") {
162+
.alert(String(localized: "Enter password", comment: "Password alert"), isPresented: $model.presentPasswordEntry) {
163+
SecureField(String(localized: "Password", comment: "Password alert"), text: $password)
164+
Button(String(localized: "Cancel", comment: "Password alert"), role: .cancel) { password = "" }
165+
Button(String(localized: "Ok", comment: "Password alert")) {
166166
model.password.send(password)
167167
password = ""
168168
}
169169
} message: {
170170
Text(model.passwordEntryMessage)
171171
}
172-
.alertOrConfirmationDialog("Save password?", isPresented: $model.presentPasswordSaveType) {
173-
Button("Save password") { model.passwordSaveType.send(.some(.save)) }
172+
.alertOrConfirmationDialog(String(localized: "Save password?", comment: "Save password alert"), isPresented: $model.presentPasswordSaveType) {
173+
Button("Save password", comment: "Save password alert.") { model.passwordSaveType.send(.some(.save)) }
174174
let authenticationType = PasswordPreferences.evaluatedAuthenticationType()
175175
if authenticationType != .none {
176176
Button("Save and protect with \(authenticationType.title)") { model.passwordSaveType.send(.some(.lock)) }
177177
}
178-
Button("Never for this YubiKey") { model.passwordSaveType.send(.some(.never)) }
179-
Button("Not now" , role: .cancel) { model.passwordSaveType.send(nil) }
178+
Button("Never for this YubiKey", comment: "Save password alert.") { model.passwordSaveType.send(.some(.never)) }
179+
Button("Not now", comment: "Save passsword alert" , role: .cancel) { model.passwordSaveType.send(nil) }
180180
}
181181
.errorAlert(error: $model.sessionError)
182182
.errorAlert(error: $model.connectionError) { model.start() }

LocalizationScreenshots/1-start.jpeg

215 KB
Loading
Loading
Loading
Loading
352 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

LocalizationScreenshots/24-about.jpeg

416 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
194 KB
Loading
Loading
Loading
Loading
362 KB
Loading
908 KB
Loading

LocalizationScreenshots/6-rename.jpeg

202 KB
Loading
1.04 MB
Loading
504 KB
Loading
Loading

0 commit comments

Comments
 (0)