From cc8e863c8420f9833ec4eaed96bb16e1dd83aece Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 2 Jan 2025 13:33:23 -0500 Subject: [PATCH] Remove duplicated Strings.ok --- .../Classes/Services/PostCoordinator.swift | 15 ++---- .../Classes/Users/Views/UserDetailsView.swift | 9 +--- .../SubmitFeedbackViewController.swift | 6 +-- .../PushAuthenticationManager.swift | 13 +++-- WordPress/Classes/Utility/ZendeskUtils.swift | 10 ++-- .../AztecPostViewController.swift | 2 +- .../Blog/Sharing/KeyringAccountHelper.swift | 2 +- .../SharingButtonsViewController.swift | 2 +- .../DeleteSiteViewController.swift | 53 +++++++++---------- ...ettingsViewController+SiteManagement.swift | 4 +- .../SiteTagsViewController.swift | 2 +- .../StartOverViewController.swift | 7 +-- .../RegisterDomainDetailsViewController.swift | 6 +-- ...tpackScanThreatDetailsViewController.swift | 10 ++-- .../Media/MediaPicker/MediaPickerMenu.swift | 3 +- .../NotificationsViewController.swift | 13 +---- .../InvitePersonViewController.swift | 3 +- .../ViewRelated/Post/PostEditor+Publish.swift | 3 +- .../PostSettingsViewController+Swift.swift | 2 +- .../ReaderStreamViewController.swift | 6 +-- .../Manage/ReaderTagsTableViewModel.swift | 4 +- .../FancyAlerts+VerificationPrompt.swift | 9 ++-- .../Themes/ThemeBrowserViewController.swift | 6 +-- .../Voice/VoiceToContentView.swift | 3 +- 24 files changed, 72 insertions(+), 121 deletions(-) diff --git a/WordPress/Classes/Services/PostCoordinator.swift b/WordPress/Classes/Services/PostCoordinator.swift index 00953e877eb0..61d633c4abde 100644 --- a/WordPress/Classes/Services/PostCoordinator.swift +++ b/WordPress/Classes/Services/PostCoordinator.swift @@ -18,7 +18,7 @@ class PostCoordinator: NSObject { case maximumRetryTimeIntervalReached var errorDescription: String? { - Strings.genericErrorTitle + SharedStrings.Error.generic } var errorUserInfo: [String: Any] { @@ -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) } @@ -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") -} diff --git a/WordPress/Classes/Users/Views/UserDetailsView.swift b/WordPress/Classes/Users/Views/UserDetailsView.swift index a1bc81e2113e..2785de5fd482 100644 --- a/WordPress/Classes/Users/Views/UserDetailsView.swift +++ b/WordPress/Classes/Users/Views/UserDetailsView.swift @@ -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" - ) - } } @@ -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 } }, diff --git a/WordPress/Classes/Utility/In-App Feedback/SubmitFeedbackViewController.swift b/WordPress/Classes/Utility/In-App Feedback/SubmitFeedbackViewController.swift index 6eccce8e7a2e..0129e0cf7c38 100644 --- a/WordPress/Classes/Utility/In-App Feedback/SubmitFeedbackViewController.swift +++ b/WordPress/Classes/Utility/In-App Feedback/SubmitFeedbackViewController.swift @@ -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 { @@ -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 @@ -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") diff --git a/WordPress/Classes/Utility/Notifications/PushAuthenticationManager.swift b/WordPress/Classes/Utility/Notifications/PushAuthenticationManager.swift index 8c03452cf608..f31f09ae2245 100644 --- a/WordPress/Classes/Utility/Notifications/PushAuthenticationManager.swift +++ b/WordPress/Classes/Utility/Notifications/PushAuthenticationManager.swift @@ -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, @@ -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, diff --git a/WordPress/Classes/Utility/ZendeskUtils.swift b/WordPress/Classes/Utility/ZendeskUtils.swift index 546a0a37cd68..2dcbbd89a9f7 100644 --- a/WordPress/Classes/Utility/ZendeskUtils.swift +++ b/WordPress/Classes/Utility/ZendeskUtils.swift @@ -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") @@ -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 ) } @@ -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 ) } } diff --git a/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift b/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift index 8b88ea4f9ef2..2d49990264a2 100644 --- a/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift +++ b/WordPress/Classes/ViewRelated/Aztec/ViewControllers/AztecPostViewController.swift @@ -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)) present(alertController, animated: true) return } diff --git a/WordPress/Classes/ViewRelated/Blog/Sharing/KeyringAccountHelper.swift b/WordPress/Classes/ViewRelated/Blog/Sharing/KeyringAccountHelper.swift index c549d73a78d3..a68d0bdf80b7 100644 --- a/WordPress/Classes/ViewRelated/Blog/Sharing/KeyringAccountHelper.swift +++ b/WordPress/Classes/ViewRelated/Blog/Sharing/KeyringAccountHelper.swift @@ -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, diff --git a/WordPress/Classes/ViewRelated/Blog/Sharing/SharingButtonsViewController.swift b/WordPress/Classes/ViewRelated/Blog/Sharing/SharingButtonsViewController.swift index e2eb28ad0cf2..833e17ee896d 100644 --- a/WordPress/Classes/ViewRelated/Blog/Sharing/SharingButtonsViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Sharing/SharingButtonsViewController.swift @@ -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() } diff --git a/WordPress/Classes/ViewRelated/Blog/Site Management/DeleteSiteViewController.swift b/WordPress/Classes/ViewRelated/Blog/Site Management/DeleteSiteViewController.swift index 5e62d654abed..92abdc23ef10 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Management/DeleteSiteViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Management/DeleteSiteViewController.swift @@ -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() }) } diff --git a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift index 061cff44b7f4..bbf63ae4bdac 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift @@ -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() @@ -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() diff --git a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteTagsViewController.swift b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteTagsViewController.swift index b65590deea58..e0dd2ecc49d8 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteTagsViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteTagsViewController.swift @@ -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) diff --git a/WordPress/Classes/ViewRelated/Blog/Site Management/StartOverViewController.swift b/WordPress/Classes/ViewRelated/Blog/Site Management/StartOverViewController.swift index 359e182588c6..e1e089fa7861 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Management/StartOverViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Management/StartOverViewController.swift @@ -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() } diff --git a/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainDetails/ViewController/RegisterDomainDetailsViewController.swift b/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainDetails/ViewController/RegisterDomainDetailsViewController.swift index c0c3d5b69f8d..25fc91de5f33 100644 --- a/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainDetails/ViewController/RegisterDomainDetailsViewController.swift +++ b/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainDetails/ViewController/RegisterDomainDetailsViewController.swift @@ -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) } diff --git a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Scan/JetpackScanThreatDetailsViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Scan/JetpackScanThreatDetailsViewController.swift index 543ee7952759..5b694b1cf27f 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Scan/JetpackScanThreatDetailsViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Scan/JetpackScanThreatDetailsViewController.swift @@ -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 } @@ -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 } @@ -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.") } } diff --git a/WordPress/Classes/ViewRelated/Media/MediaPicker/MediaPickerMenu.swift b/WordPress/Classes/ViewRelated/Media/MediaPicker/MediaPickerMenu.swift index 472b38236fed..a0204f0b1beb 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaPicker/MediaPickerMenu.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaPicker/MediaPickerMenu.swift @@ -142,7 +142,7 @@ extension MediaPickerMenu { private func showAccessRestrictedAlert() { let alert = UIAlertController(title: Strings.noCameraAccessTitle, message: Strings.noCameraAccessMessage, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: Strings.buttonOK, style: .cancel)) + alert.addAction(UIAlertAction(title: SharedStrings.Button.ok, style: .cancel)) alert.addAction(UIAlertAction(title: Strings.noCameraOpenSettings, style: .default) { _ in guard let url = URL(string: UIApplication.openSettingsURLString) else { return assertionFailure("Failed to create Open Settigns URL") @@ -300,5 +300,4 @@ private enum Strings { static let noCameraAccessTitle = NSLocalizedString("mediaPicker.noCameraAccessTitle", value: "Media Capture", comment: "Title for alert when access to camera is not granted") static let noCameraAccessMessage = NSLocalizedString("mediaPicker.noCameraAccessMessage", value: "This app needs permission to access the Camera to capture new media, please change the privacy settings if you wish to allow this.", comment: "Message for alert when access to camera is not granted") static let noCameraOpenSettings = NSLocalizedString("mediaPicker.openSettings", value: "Open Settings", comment: "Button that opens the Settings app") - static let buttonOK = NSLocalizedString("OK", value: "OK", comment: "OK") } diff --git a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift index a2eb3fd09fd4..ac5d2d6970be 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationsViewController/NotificationsViewController.swift @@ -1107,15 +1107,6 @@ private extension NotificationsViewController { ) } - let cancelTitle = NSLocalizedString( - "Cancel", - comment: "Cancels the mark all as read action." - ) - let markAllTitle = NSLocalizedString( - "OK", - comment: "Marks all notifications as read." - ) - let alertController = UIAlertController( title: String.localizedStringWithFormat(title, filter.confirmationMessageTitle), message: nil, @@ -1123,9 +1114,9 @@ private extension NotificationsViewController { ) alertController.view.accessibilityIdentifier = "mark-all-as-read-alert" - alertController.addCancelActionWithTitle(cancelTitle) + alertController.addCancelActionWithTitle(SharedStrings.Button.cancel) - alertController.addActionWithTitle(markAllTitle, style: .default) { [weak self] _ in + alertController.addActionWithTitle(SharedStrings.Button.ok, style: .default) { [weak self] _ in self?.markAllAsRead() } diff --git a/WordPress/Classes/ViewRelated/People/Controllers/InvitePersonViewController.swift b/WordPress/Classes/ViewRelated/People/Controllers/InvitePersonViewController.swift index 4131d7a8e2c3..5cfae7c98479 100644 --- a/WordPress/Classes/ViewRelated/People/Controllers/InvitePersonViewController.swift +++ b/WordPress/Classes/ViewRelated/People/Controllers/InvitePersonViewController.swift @@ -545,10 +545,9 @@ private extension InvitePersonViewController { let message = messageMap[error] ?? messageMap[.unknownError]! let title = NSLocalizedString("Sorry!", comment: "Invite Validation Alert") - let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title") let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) - alert.addDefaultActionWithTitle(okTitle) + alert.addDefaultActionWithTitle(SharedStrings.Button.ok) present(alert, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift b/WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift index 410d3df38e61..fc616c29c925 100644 --- a/WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift +++ b/WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift @@ -147,7 +147,7 @@ extension PublishingEditor { func displayMediaIsUploadingAlert() { let alertController = UIAlertController(title: MediaUploadingAlert.title, message: MediaUploadingAlert.message, preferredStyle: .alert) - alertController.addDefaultActionWithTitle(MediaUploadingAlert.acceptTitle) + alertController.addDefaultActionWithTitle(SharedStrings.Button.ok) present(alertController, animated: true, completion: nil) } @@ -359,5 +359,4 @@ private enum Strings { private struct MediaUploadingAlert { static let title = NSLocalizedString("Uploading media", comment: "Title for alert when trying to save/exit a post before media upload process is complete.") static let message = NSLocalizedString("You are currently uploading media. Please wait until this completes.", comment: "This is a notification the user receives if they are trying to save a post (or exit) before the media upload process is complete.") - static let acceptTitle = NSLocalizedString("OK", comment: "Accept Action") } diff --git a/WordPress/Classes/ViewRelated/Post/PostSettingsViewController+Swift.swift b/WordPress/Classes/ViewRelated/Post/PostSettingsViewController+Swift.swift index 6cd78ab87e76..c8def4b258e0 100644 --- a/WordPress/Classes/ViewRelated/Post/PostSettingsViewController+Swift.swift +++ b/WordPress/Classes/ViewRelated/Post/PostSettingsViewController+Swift.swift @@ -177,7 +177,7 @@ extension PostSettingsViewController { private func showWarningPostWillBePublishedAlert() { let alert = UIAlertController(title: nil, message: Strings.warningPostWillBePublishedAlertMessage, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: NSLocalizedString("postSettings.ok", value: "OK", comment: "Button OK"), style: .default)) + alert.addAction(UIAlertAction(title: SharedStrings.Button.ok, style: .default)) present(alert, animated: true) } } diff --git a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift index 5b8b266697c2..612dfec0326a 100644 --- a/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift +++ b/WordPress/Classes/ViewRelated/Reader/Controllers/ReaderStreamViewController.swift @@ -886,11 +886,10 @@ import AutomatticTracks if !canSync() { let alertTitle = NSLocalizedString("Unable to Load Posts", comment: "Title of a prompt saying the app needs an internet connection before it can load posts") let alertMessage = NSLocalizedString("Please check your internet connection and try again.", comment: "Politely asks the user to check their internet connection before trying again. ") - let cancelTitle = NSLocalizedString("OK", comment: "Title of a button that dismisses a prompt") let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) - alertController.addCancelActionWithTitle(cancelTitle, handler: nil) + alertController.addCancelActionWithTitle(SharedStrings.Button.ok, handler: nil) alertController.presentFromRootViewController() return @@ -898,11 +897,10 @@ import AutomatticTracks if let syncHelper, syncHelper.isSyncing { let alertTitle = NSLocalizedString("Busy", comment: "Title of a prompt letting the user know that they must wait until the current aciton completes.") let alertMessage = NSLocalizedString("Please wait until the current fetch completes.", comment: "Asks the user to wait until the currently running fetch request completes.") - let cancelTitle = NSLocalizedString("OK", comment: "Title of a button that dismisses a prompt") let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) - alertController.addCancelActionWithTitle(cancelTitle, handler: nil) + alertController.addCancelActionWithTitle(SharedStrings.Button.ok, handler: nil) alertController.presentFromRootViewController() return diff --git a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift index d89f3c859b18..2cb097abeb7e 100644 --- a/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift +++ b/WordPress/Classes/ViewRelated/Reader/Manage/ReaderTagsTableViewModel.swift @@ -198,7 +198,7 @@ extension ReaderTagsTableViewModel { let title = NSLocalizedString("Could Not Follow Topic", comment: "Title of a prompt informing the user there was a probem unsubscribing from a topic in the reader.") let message = error?.localizedDescription let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) - alert.addCancelActionWithTitle(NSLocalizedString("OK", comment: "Button title. An acknowledgement of the message displayed in a prompt.")) + alert.addCancelActionWithTitle(SharedStrings.Button.ok) alert.presentFromRootViewController() }, source: "manage") } @@ -215,7 +215,7 @@ extension ReaderTagsTableViewModel { let title = NSLocalizedString("Could Not Remove Topic", comment: "Title of a prompt informing the user there was a probem unsubscribing from a topic in the reader.") let message = error?.localizedDescription let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) - alert.addCancelActionWithTitle(NSLocalizedString("OK", comment: "Button title. An acknowledgement of the message displayed in a prompt.")) + alert.addCancelActionWithTitle(SharedStrings.Button.ok) alert.presentFromRootViewController() } } diff --git a/WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlerts+VerificationPrompt.swift b/WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlerts+VerificationPrompt.swift index d13ca4b330bc..b287ecb264e6 100644 --- a/WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlerts+VerificationPrompt.swift +++ b/WordPress/Classes/ViewRelated/System/Fancy Alerts/FancyAlerts+VerificationPrompt.swift @@ -36,7 +36,7 @@ extension FancyAlertViewController { }) } - let defaultButton = FancyAlertViewController.Config.ButtonConfig(Strings.ok) { controller, _ in + let defaultButton = FancyAlertViewController.Config.ButtonConfig(SharedStrings.Button.ok) { controller, _ in completion?() controller.dismiss(animated: true) } @@ -55,7 +55,7 @@ extension FancyAlertViewController { } private static func successfullySentVerificationEmailConfig() -> FancyAlertViewController.Config { - let okButton = FancyAlertViewController.Config.ButtonConfig(Strings.ok) { controller, _ in + let okButton = FancyAlertViewController.Config.ButtonConfig(SharedStrings.Button.ok) { controller, _ in controller.dismiss(animated: true) } @@ -71,7 +71,7 @@ extension FancyAlertViewController { } private static func failureSendingVerificationEmailConfig(with error: VerificationFailureError) -> FancyAlertViewController.Config { - let okButton = FancyAlertViewController.Config.ButtonConfig(Strings.ok) { controller, _ in + let okButton = FancyAlertViewController.Config.ButtonConfig(SharedStrings.Button.ok) { controller, _ in controller.dismiss(animated: true) } @@ -103,9 +103,6 @@ extension FancyAlertViewController { static let resendEmail = NSLocalizedString("Resend", comment: "Title of secondary button on alert prompting verify their accounts while attempting to publish") - static let ok = NSLocalizedString("OK", - comment: "Title of primary button on alert prompting verify their accounts while attempting to publish") - static let emailSentSuccesfully = NSLocalizedString("Verification email sent, check your inbox.", comment: "Message shown when a verification email was re-sent succesfully") diff --git a/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift b/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift index 65ad2b50374f..7d37c1187616 100644 --- a/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift +++ b/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift @@ -782,7 +782,6 @@ public protocol ThemePresenter: AnyObject { let successFormat = NSLocalizedString("Thanks for choosing %@ by %@", comment: "Message of alert when theme activation succeeds") let successMessage = String(format: successFormat, theme?.name ?? "", theme?.author ?? "") let manageTitle = NSLocalizedString("Manage site", comment: "Return to blog screen action when theme activation succeeds") - let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title") self?.updateActivateButton(isLoading: false) @@ -794,14 +793,13 @@ public protocol ThemePresenter: AnyObject { handler: { [weak self] (action: UIAlertAction) in _ = self?.navigationController?.popViewController(animated: true) }) - alertController.addDefaultActionWithTitle(okTitle, handler: nil) + alertController.addDefaultActionWithTitle(SharedStrings.Button.ok, handler: nil) alertController.presentFromRootViewController() }, failure: { [weak self] (error) in DDLogError("Error activating theme \(String(describing: theme.themeId)): \(String(describing: error?.localizedDescription))") let errorTitle = NSLocalizedString("Activation Error", comment: "Title of alert when theme activation fails") - let okTitle = NSLocalizedString("OK", comment: "Alert dismissal title") self?.activityIndicator.stopAnimating() self?.activateButton?.customView = nil @@ -809,7 +807,7 @@ public protocol ThemePresenter: AnyObject { let alertController = UIAlertController(title: errorTitle, message: error?.localizedDescription, preferredStyle: .alert) - alertController.addDefaultActionWithTitle(okTitle, handler: nil) + alertController.addDefaultActionWithTitle(SharedStrings.Button.ok, handler: nil) alertController.presentFromRootViewController() }) } diff --git a/WordPress/Classes/ViewRelated/Voice/VoiceToContentView.swift b/WordPress/Classes/ViewRelated/Voice/VoiceToContentView.swift index 66445dd8931c..74b5cbfa3ecd 100644 --- a/WordPress/Classes/ViewRelated/Voice/VoiceToContentView.swift +++ b/WordPress/Classes/ViewRelated/Voice/VoiceToContentView.swift @@ -10,7 +10,7 @@ struct VoiceToContentView: View { .onAppear(perform: viewModel.onViewAppeared) .tint(Color(uiColor: UIAppColor.brand)) .alert(viewModel.errorAlertMessage ?? "", isPresented: $viewModel.isShowingErrorAlert, actions: { - Button(Strings.ok, action: buttonCancelTapped) + Button(SharedStrings.Button.ok, action: buttonCancelTapped) }) } @@ -189,6 +189,5 @@ private enum Strings { static let retry = NSLocalizedString("postFromAudio.retry", value: "Retry", comment: "Button title") static let notEnoughRequests = NSLocalizedString("postFromAudio.notEnoughRequestsMessage", value: "You don't have enough requests available to create a post from audio.", comment: "Message for 'not eligible' state view") static let upgrade = NSLocalizedString("postFromAudio.buttonUpgrade", value: "Upgrade for more requests", comment: "Button title") - static let ok = NSLocalizedString("postFromAudio.ok", value: "OK", comment: "Button title") static let close = NSLocalizedString("postFromAudio.close", value: "Close", comment: "Button close title (only used as an accessibility identifier)") }