Skip to content

Commit c70a8bc

Browse files
committed
Extract localized strings to an enum
1 parent d468cb2 commit c70a8bc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+SectionHelpers.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ struct ApplicationPasswordRequiredView<Content: View>: View {
195195
@MainActor
196196
private func migrate() async {
197197
guard let url = try? blog.getUrlString() else {
198-
let error = NSLocalizedString("applicationPasswordMigration.error.siteUrlNotFound", value: "Cannot find the current site's url", comment: "Error message when the current site's url cannot be found")
199-
Notice(title: error).post()
198+
Notice(title: Strings.siteUrlNotFoundError).post()
200199
return
201200
}
202201

@@ -207,8 +206,7 @@ struct ApplicationPasswordRequiredView<Content: View>: View {
207206

208207
// Ensure the application password belongs to the current signed in user
209208
if let username = blog.username, success.userLogin != username {
210-
let format = NSLocalizedString("applicationPasswordMigration.error.usernameMismatch", value: "You need to sign in with user \"%@\"", comment: "Error message when the username does not match the signed-in user. The first argument is the currently signed in user's user login name")
211-
Notice(title: .localizedStringWithFormat(format, username)).post()
209+
Notice(title: Strings.userNameMismatch(expected: username)).post()
212210
return
213211
}
214212

@@ -224,4 +222,15 @@ struct ApplicationPasswordRequiredView<Content: View>: View {
224222
Notice(title: SharedStrings.Error.generic).post()
225223
}
226224
}
225+
226+
enum Strings {
227+
static var siteUrlNotFoundError: String {
228+
NSLocalizedString("applicationPasswordMigration.error.siteUrlNotFound", value: "Cannot find the current site's url", comment: "Error message when the current site's url cannot be found")
229+
}
230+
231+
static func userNameMismatch(expected: String) -> String {
232+
let format = NSLocalizedString("applicationPasswordMigration.error.usernameMismatch", value: "You need to sign in with user \"%@\"", comment: "Error message when the username does not match the signed-in user. The first argument is the currently signed in user's user login name")
233+
return String(format: format, expected)
234+
}
235+
}
227236
}

0 commit comments

Comments
 (0)