Skip to content

Commit

Permalink
Remove duplicated Strings.ok
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jan 2, 2025
1 parent 3d4bc9d commit 4c26d71
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 121 deletions.
15 changes: 5 additions & 10 deletions WordPress/Classes/Services/PostCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PostCoordinator: NSObject {
case maximumRetryTimeIntervalReached

var errorDescription: String? {
Strings.genericErrorTitle
SharedStrings.Error.generic
}

var errorUserInfo: [String: Any] {
Expand Down Expand Up @@ -177,20 +177,20 @@ class PostCoordinator: NSObject {
wpAssertionFailure("Failed to show an error alert")
return
}
let alert = UIAlertController(title: Strings.genericErrorTitle, message: error.localizedDescription, preferredStyle: .alert)
let alert = UIAlertController(title: SharedStrings.Error.generic, message: error.localizedDescription, preferredStyle: .alert)
if let error = error as? PostRepository.PostSaveError {
switch error {
case .conflict(let latest):
alert.addDefaultActionWithTitle(Strings.buttonOK) { [weak self] _ in
alert.addDefaultActionWithTitle(SharedStrings.Button.ok) { [weak self] _ in
self?.showResolveConflictView(post: post, remoteRevision: latest, source: .editor)
}
case .deleted:
alert.addDefaultActionWithTitle(Strings.buttonOK) { [weak self] _ in
alert.addDefaultActionWithTitle(SharedStrings.Button.ok) { [weak self] _ in
self?.handlePermanentlyDeleted(post)
}
}
} else {
alert.addDefaultActionWithTitle(Strings.buttonOK, handler: nil)
alert.addDefaultActionWithTitle(SharedStrings.Button.ok, handler: nil)
}
topViewController.present(alert, animated: true)
}
Expand Down Expand Up @@ -945,8 +945,3 @@ private extension NSManagedObjectID {
.trimmingCharacters(in: CharacterSet(charactersIn: "/>"))
}
}

private enum Strings {
static let genericErrorTitle = NSLocalizedString("postNotice.errorTitle", value: "An error occured", comment: "A generic error message title")
static let buttonOK = NSLocalizedString("postNotice.ok", value: "OK", comment: "Button OK")
}
9 changes: 1 addition & 8 deletions WordPress/Classes/Users/Views/UserDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,6 @@ struct UserDetailsView: View {
value: "There was an error deleting the user.",
comment: "The message in the alert that appears when deleting a user"
)

static let deleteUserErrorAlertOkButton = NSLocalizedString(
"userDetails.alert.deleteUserErrorAlertOkButton",
value: "OK",
comment: "The title of the OK button in the alert that appears when deleting a user"
)

}
}

Expand Down Expand Up @@ -293,7 +286,7 @@ private extension View {
isPresented: view.$presentDeleteUserError,
presenting: view.deleteUserViewModel.error,
actions: { _ in
Button(Strings.deleteUserErrorAlertOkButton) {
Button(SharedStrings.Button.ok) {
view.presentDeleteUserError = false
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private struct SubmitFeedbackView: View {
.listStyle(.plain)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button(Strings.cancel) {
Button(SharedStrings.Button.cancel) {
if isInputEmpty {
dismiss()
} else {
Expand Down Expand Up @@ -87,7 +87,7 @@ private struct SubmitFeedbackView: View {
}
}
.alert(Strings.attachmentsStillUploadingAlertTitle, isPresented: $isShowingAttachmentsUploadingAlert) {
Button(Strings.ok) {}
Button(SharedStrings.Button.ok) {}
}
.onChange(of: isInputEmpty) {
presentingViewController?.isModalInPresentation = !$0
Expand Down Expand Up @@ -179,8 +179,6 @@ private struct SubmitFeedbackView: View {
}

private enum Strings {
static let ok = NSLocalizedString("submit.feedback.buttonOK", value: "OK", comment: "The button title for the Cancel button in the In-App Feedback screen")
static let cancel = NSLocalizedString("submit.feedback.buttonCancel", value: "Cancel", comment: "The button title for the Cancel button in the In-App Feedback screen")
static let submit = NSLocalizedString("submit.feedback.submit.button", value: "Submit", comment: "The button title for the Submit button in the In-App Feedback screen")
static let title = NSLocalizedString("submit.feedback.title", value: "Feedback", comment: "The title for the the In-App Feedback screen")
static let details = NSLocalizedString("submit.feedback.detailsPlaceholder", value: "Details", comment: "The section title and or placeholder")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ private extension PushAuthenticationManager {
/// Displays an AlertView indicating that a Login Request has expired.
///
func showLoginExpiredAlert() {
let title = NSLocalizedString("Login Request Expired", comment: "Login Request Expired")
let message = NSLocalizedString("The login request has expired. Log in to WordPress.com to try again.",
comment: "WordPress.com Push Authentication Expired message")
let acceptButtonTitle = NSLocalizedString("OK", comment: "OK")
let title = NSLocalizedString("Login Request Expired", comment: "Login Request Expired")
let message = NSLocalizedString("The login request has expired. Log in to WordPress.com to try again.", comment: "WordPress.com Push Authentication Expired message")
let acceptButtonTitle = SharedStrings.Button.ok

alertControllerProxy.show(withTitle: title,
message: message,
Expand All @@ -147,9 +146,9 @@ private extension PushAuthenticationManager {
/// - completion: A closure that receives a parameter, indicating whether the login attempt was confirmed or not.
///
func showLoginVerificationAlert(_ message: String, completion: @escaping ((_ approved: Bool) -> ())) {
let title = NSLocalizedString("Verify Log In", comment: "Push Authentication Alert Title")
let cancelButtonTitle = NSLocalizedString("Ignore", comment: "Ignore action. Verb")
let acceptButtonTitle = NSLocalizedString("Approve", comment: "Approve action. Verb")
let title = NSLocalizedString("Verify Log In", comment: "Push Authentication Alert Title")
let cancelButtonTitle = NSLocalizedString("Ignore", comment: "Ignore action. Verb")
let acceptButtonTitle = NSLocalizedString("Approve", comment: "Approve action. Verb")

alertControllerProxy.show(withTitle: title,
message: message,
Expand Down
10 changes: 4 additions & 6 deletions WordPress/Classes/Utility/ZendeskUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,6 @@ private extension ZendeskUtils {
struct LocalizedText {
static let alertMessageWithName = NSLocalizedString("To continue please enter your email address and name.", comment: "Instructions for alert asking for email and name.")
static let alertMessage = NSLocalizedString("Please enter your email address.", comment: "Instructions for alert asking for email.")
static let alertSubmit = NSLocalizedString("OK", comment: "Submit button on prompt for user information.")
static let alertCancel = NSLocalizedString("Cancel", comment: "Cancel prompt for user information.")
static let emailPlaceholder = NSLocalizedString("Email", comment: "Email address text field placeholder")
static let emailAccessibilityLabel = NSLocalizedString("Email", comment: "Accessibility label for the Email text field.")
static let namePlaceholder = NSLocalizedString("Name", comment: "Name text field placeholder")
Expand Down Expand Up @@ -1192,8 +1190,8 @@ extension ZendeskUtils {
optionalIdentity: false,
includesName: true,
message: LocalizedText.alertMessageWithName,
submit: LocalizedText.alertSubmit,
cancel: LocalizedText.alertCancel
submit: SharedStrings.Button.ok,
cancel: SharedStrings.Button.cancel
)
}

Expand All @@ -1202,8 +1200,8 @@ extension ZendeskUtils {
optionalIdentity: false,
includesName: false,
message: LocalizedText.alertMessage,
submit: LocalizedText.alertSubmit,
cancel: LocalizedText.alertCancel
submit: SharedStrings.Button.ok,
cancel: SharedStrings.Button.cancel
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,7 @@ extension AztecPostViewController {

func displayUnableToPlayVideoAlert() {
let alertController = UIAlertController(title: MediaUnableToPlayVideoAlert.title, message: MediaUnableToPlayVideoAlert.message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Default action"), style: .`default`, handler: nil))
alertController.addAction(UIAlertAction(title: SharedStrings.Button.ok, style: .default, handler: nil))
present(alertController, animated: true)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private extension KeyringAccountHelper {
let alertBodyMessage = NSLocalizedString("The Facebook connection cannot find any Pages. Publicize cannot connect to Facebook Profiles, only published Pages.",
comment: "Error message shown to a user who is trying to share to Facebook but does not have any available Facebook Pages.")
let continueActionTitle = NSLocalizedString("Learn more", comment: "A button title.")
let cancelActionTitle = NSLocalizedString("OK", comment: "A button title for closing the dialog.")
let cancelActionTitle = SharedStrings.Button.ok

return ValidationError(header: alertHeaderMessage,
body: alertBodyMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ import WordPressShared
message.append(error.localizedDescription)
}
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addCancelActionWithTitle(NSLocalizedString("OK", comment: "A button title."), handler: nil)
controller.addCancelActionWithTitle(SharedStrings.Button.ok, handler: nil)

controller.presentFromRootViewController()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,34 +215,31 @@ open class DeleteSiteViewController: UITableViewController {
let trackedBlog = blog
WPAppAnalytics.track(.siteSettingsDeleteSiteRequested, with: trackedBlog)
let service = SiteManagementService(coreDataStack: ContextManager.sharedInstance())
service.deleteSiteForBlog(blog,
success: { [weak self] in
WPAppAnalytics.track(.siteSettingsDeleteSiteResponseOK, with: trackedBlog)
let status = NSLocalizedString("Site deleted", comment: "Overlay message displayed when site successfully deleted")
SVProgressHUD.showDismissibleSuccess(withStatus: status)

self?.updateNavigationStackAfterSiteDeletion()

let context = ContextManager.shared.mainContext
let account = try? WPAccount.lookupDefaultWordPressComAccount(in: context)
if let account {
AccountService(coreDataStack: ContextManager.sharedInstance()).updateUserDetails(for: account,
success: {},
failure: { _ in })
}
},
failure: { error in
DDLogError("Error deleting site: \(error.localizedDescription)")
WPAppAnalytics.track(.siteSettingsDeleteSiteResponseError, with: trackedBlog)
SVProgressHUD.dismiss()

let errorTitle = NSLocalizedString("Delete Site Error", comment: "Title of alert when site deletion fails")
let alertController = UIAlertController(title: errorTitle, message: error.localizedDescription, preferredStyle: .alert)

let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title")
alertController.addDefaultActionWithTitle(okTitle, handler: nil)

alertController.presentFromRootViewController()
service.deleteSiteForBlog(blog, success: { [weak self] in
WPAppAnalytics.track(.siteSettingsDeleteSiteResponseOK, with: trackedBlog)
let status = NSLocalizedString("Site deleted", comment: "Overlay message displayed when site successfully deleted")
SVProgressHUD.showDismissibleSuccess(withStatus: status)

self?.updateNavigationStackAfterSiteDeletion()

let context = ContextManager.shared.mainContext
let account = try? WPAccount.lookupDefaultWordPressComAccount(in: context)
if let account {
AccountService(coreDataStack: ContextManager.sharedInstance()).updateUserDetails(for: account,
success: {},
failure: { _ in })
}
}, failure: { error in
DDLogError("Error deleting site: \(error.localizedDescription)")
WPAppAnalytics.track(.siteSettingsDeleteSiteResponseError, with: trackedBlog)
SVProgressHUD.dismiss()

let errorTitle = NSLocalizedString("Delete Site Error", comment: "Title of alert when site deletion fails")
let alertController = UIAlertController(title: errorTitle, message: error.localizedDescription, preferredStyle: .alert)

alertController.addDefaultActionWithTitle(SharedStrings.Button.ok, handler: nil)

alertController.presentFromRootViewController()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public extension SiteSettingsViewController {
let errorTitle = NSLocalizedString("Export Content Error", comment: "Title of alert when export content fails")
let alertController = UIAlertController(title: errorTitle, message: error.localizedDescription, preferredStyle: .alert)

let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title")
let okTitle = SharedStrings.Button.ok
_ = alertController.addDefaultActionWithTitle(okTitle, handler: nil)

alertController.presentFromRootViewController()
Expand Down Expand Up @@ -101,7 +101,7 @@ public extension SiteSettingsViewController {
let errorTitle = NSLocalizedString("Check Purchases Error", comment: "Title of alert when getting purchases fails")
let alertController = UIAlertController(title: errorTitle, message: error.localizedDescription, preferredStyle: .alert)

let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title")
let okTitle = SharedStrings.Button.ok
alertController.addDefaultActionWithTitle(okTitle, handler: nil)

alertController.presentFromRootViewController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ extension SiteTagsViewController {
comment: "Message of the alert indicating that a tag with that name already exists. The placeholder is the name of the tag"),
tagName)

let acceptTitle = NSLocalizedString("OK", comment: "Alert dismissal title")
let acceptTitle = SharedStrings.Button.ok
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertController.addDefaultActionWithTitle(acceptTitle)
present(alertController, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,8 @@ open class StartOverViewController: UITableViewController, MFMailComposeViewCont
let title = String(format: NSLocalizedString("Contact us at %@", comment: "Alert title for contact us alert, placeholder for help email address, inserted at run time."), mailRecipient)
let message = NSLocalizedString("\nPlease send us an email to have your content cleared out.", comment: "Message to ask the user to send us an email to clear their content.")

let alertController = UIAlertController(title: title,
message: message,
preferredStyle: .alert)
alertController.addCancelActionWithTitle(NSLocalizedString("OK",
comment: "Button title. An acknowledgement of the message displayed in a prompt."))
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertController.addCancelActionWithTitle(SharedStrings.Button.ok)
alertController.presentFromRootViewController()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ class RegisterDomainDetailsViewController: UITableViewController {
}

private func showAlert(title: String? = nil, message: String) {
let alertCancel = NSLocalizedString(
"OK",
comment: "Title of an OK button. Pressing the button acknowledges and dismisses a prompt."
)
let alertController = UIAlertController(
title: title,
message: message,
preferredStyle: .alert
)
alertController.addCancelActionWithTitle(alertCancel, handler: nil)
alertController.addCancelActionWithTitle(SharedStrings.Button.ok, handler: nil)
present(alertController, animated: true, completion: nil)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class JetpackScanThreatDetailsViewController: UIViewController {
message: viewModel.fixDescription,
preferredStyle: .alert)

alert.addAction(UIAlertAction(title: Strings.cancel, style: .cancel))
alert.addAction(UIAlertAction(title: Strings.ok, style: .default, handler: { [weak self] _ in
alert.addAction(UIAlertAction(title: SharedStrings.Button.cancel, style: .cancel))
alert.addAction(UIAlertAction(title: SharedStrings.Button.ok, style: .default, handler: { [weak self] _ in
guard let self else {
return
}
Expand All @@ -105,8 +105,8 @@ class JetpackScanThreatDetailsViewController: UIViewController {
message: String(format: viewModel.ignoreActionMessage, blogName),
preferredStyle: .alert)

alert.addAction(UIAlertAction(title: Strings.cancel, style: .cancel))
alert.addAction(UIAlertAction(title: Strings.ok, style: .default, handler: { [weak self] _ in
alert.addAction(UIAlertAction(title: SharedStrings.Button.cancel, style: .cancel))
alert.addAction(UIAlertAction(title: SharedStrings.Button.ok, style: .default, handler: { [weak self] _ in
guard let self else {
return
}
Expand Down Expand Up @@ -274,8 +274,6 @@ extension JetpackScanThreatDetailsViewController {

private enum Strings {
static let title = NSLocalizedString("Threat details", comment: "Title for the Jetpack Scan Threat Details screen")
static let ok = NSLocalizedString("OK", comment: "OK button for alert")
static let cancel = NSLocalizedString("Cancel", comment: "Cancel button for alert")
static let jetpackSettingsNotice = NSLocalizedString("Unable to visit Jetpack settings for site", comment: "Message displayed when visiting the Jetpack settings page fails.")
}
}
Loading

0 comments on commit 4c26d71

Please sign in to comment.