diff --git a/Account/Package.swift b/Account/Package.swift index cafc3933c..b1b5a1d4f 100644 --- a/Account/Package.swift +++ b/Account/Package.swift @@ -26,6 +26,7 @@ dependencies.append(contentsOf: [ let package = Package( name: "Account", + defaultLocalization: "en", platforms: [.macOS(SupportedPlatform.MacOSVersion.v11), .iOS(SupportedPlatform.IOSVersion.v14)], products: [ .library( diff --git a/Account/Sources/Account/AccountError.swift b/Account/Sources/Account/AccountError.swift index 75852b178..5b99568bf 100644 --- a/Account/Sources/Account/AccountError.swift +++ b/Account/Sources/Account/AccountError.swift @@ -32,21 +32,42 @@ public enum AccountError: LocalizedError { } return false } + + public var errorTitle: String { + switch self { + case .createErrorNotFound: + // TODO: Add to Localizable + return NSLocalizedString("error.title.feed-not-found", bundle: Bundle.module, comment: "Unable to Add Feed") + case .createErrorAlreadySubscribed: + // TODO: Add to Localizable + return NSLocalizedString("error.title.already-subscribed", bundle: Bundle.module, comment: "Already Subscribed") + case .opmlImportInProgress: + // TODO: Add to Localizable + return NSLocalizedString("error.title.ompl-import-in-progress", bundle: Bundle.module, comment: "OPML Import in Progress") + case .wrappedError(_, _): + // TODO: Add to Localizable + return NSLocalizedString("error.title.error", bundle: Bundle.module, comment: "Error") + } + } public var errorDescription: String? { switch self { case .createErrorNotFound: - return NSLocalizedString("The feed couldn’t be found and can’t be added.", comment: "Not found") + // TODO: Add to Localizable + return NSLocalizedString("error.message.feed-not-found", bundle: Bundle.module, comment: "Can’t add a feed because no feed was found.") case .createErrorAlreadySubscribed: - return NSLocalizedString("You are already subscribed to this feed and can’t add it again.", comment: "Already subscribed") + // TODO: Add to Localizable + return NSLocalizedString("error.message.feed-already-subscribed", bundle: Bundle.module, comment: "You are already subscribed to this feed and can’t add it again.") case .opmlImportInProgress: - return NSLocalizedString("An OPML import for this account is already running.", comment: "Import running") + // TODO: Add to Localizable + return NSLocalizedString("error.message.opml-import-in-progress", bundle: Bundle.module, comment: "An OPML import for this account is already running.") case .wrappedError(let error, let account): switch error { case TransportError.httpError(let status): if isCredentialsError(status: status) { - let localizedText = NSLocalizedString("Your “%@” credentials are invalid or expired.", comment: "Invalid or expired") - return NSString.localizedStringWithFormat(localizedText as NSString, account.nameForDisplay) as String + // TODO: Add to Localizable + let localizedText = NSLocalizedString("error.message.credentials-expired.%@", bundle: Bundle.module, comment: "Your ”%@” credentials have expired.") + return String(format: localizedText, account.nameForDisplay) } else { return unknownError(error, account) } diff --git a/Account/Sources/Account/Resources/en-GB.lproj/Localizable.strings b/Account/Sources/Account/Resources/en-GB.lproj/Localizable.strings new file mode 100644 index 000000000..852c08f67 --- /dev/null +++ b/Account/Sources/Account/Resources/en-GB.lproj/Localizable.strings @@ -0,0 +1,16 @@ +/* + Localizable.strings + + + Created by Stuart Breckenridge on 11/03/2023. + +*/ + +"error.title.feed-not-found" = "Unable to Add Feed"; +"error.title.already-subscribed" = "Already Subscribed"; +"error.title.ompl-import-in-progress" = "OPML Import in Progress"; +"error.title.error" = "Error"; + +"error.message.feed-not-found" = "Can’t add a feed because no feed was found."; +"error.message.already-subscribed" = "You are already subscribed to this feed and can’t add it again."; +"error.message.opml-import-in-progress" = "An OPML import for this account is already running."; diff --git a/Account/Sources/Account/Resources/en.lproj/Localizable.strings b/Account/Sources/Account/Resources/en.lproj/Localizable.strings new file mode 100644 index 000000000..852c08f67 --- /dev/null +++ b/Account/Sources/Account/Resources/en.lproj/Localizable.strings @@ -0,0 +1,16 @@ +/* + Localizable.strings + + + Created by Stuart Breckenridge on 11/03/2023. + +*/ + +"error.title.feed-not-found" = "Unable to Add Feed"; +"error.title.already-subscribed" = "Already Subscribed"; +"error.title.ompl-import-in-progress" = "OPML Import in Progress"; +"error.title.error" = "Error"; + +"error.message.feed-not-found" = "Can’t add a feed because no feed was found."; +"error.message.already-subscribed" = "You are already subscribed to this feed and can’t add it again."; +"error.message.opml-import-in-progress" = "An OPML import for this account is already running."; diff --git a/Mac/MainWindow/AddFeed/AddFeedController.swift b/Mac/MainWindow/AddFeed/AddFeedController.swift index d4f333af0..226d1b7c8 100644 --- a/Mac/MainWindow/AddFeed/AddFeedController.swift +++ b/Mac/MainWindow/AddFeed/AddFeedController.swift @@ -136,8 +136,8 @@ private extension AddFeedController { func showAlreadySubscribedError(_ urlString: String) { let alert = NSAlert() alert.alertStyle = .informational - alert.messageText = NSLocalizedString("alert.title.already-subscribed", comment: "Already subscribed") - alert.informativeText = NSLocalizedString("alert.message.already-subscribed", comment: "Can’t add this feed because you’ve already subscribed to it.") + alert.messageText = AccountError.createErrorAlreadySubscribed.errorTitle + alert.informativeText = AccountError.createErrorAlreadySubscribed.localizedDescription alert.beginSheetModal(for: hostWindow) } @@ -155,8 +155,8 @@ private extension AddFeedController { func showNoFeedsErrorMessage() { let alert = NSAlert() alert.alertStyle = .informational - alert.messageText = NSLocalizedString("alert.title.feed-not-found", comment: "Feed not found") - alert.informativeText = NSLocalizedString("alert.message.feed-not-found", comment: "Can’t add a feed because no feed was found.") + alert.messageText = AccountError.createErrorNotFound.errorTitle + alert.informativeText = AccountError.createErrorNotFound.localizedDescription alert.beginSheetModal(for: hostWindow) } diff --git a/Mac/Resources/en-GB.lproj/Localizable.strings b/Mac/Resources/en-GB.lproj/Localizable.strings index 75c403e88..e0db4abd2 100644 --- a/Mac/Resources/en-GB.lproj/Localizable.strings +++ b/Mac/Resources/en-GB.lproj/Localizable.strings @@ -64,9 +64,6 @@ /* You won't see this message again */ "alert.informative.will-not-see-again" = "You won't see this message again"; -/* Can’t add this feed because you’ve already subscribed to it. */ -"alert.message.already-subscribed" = "Can’t add this feed because you’ve already subscribed to it."; - /* Some articles don’t have links, so they weren't copied. */ "alert.message.articles-without-links" = "Some articles don’t have links, so they weren't copied."; @@ -101,8 +98,6 @@ /* To enable notifications, open Notifications in System Settings, then find NetNewsWire in the list. */ "alert.message.enable-notifications-in-system-settings" = "To enable notifications, open Notifications in System Settings, then find NetNewsWire in the list."; -/* Can’t add a feed because no feed was found. */ -"alert.message.feed-not-found" = "Can’t add a feed because no feed was found."; /* A web browser will open the Feedly login for you to authorize access. */ "alert.message.feedly-web-browser-information" = "A web browser will open the Feedly login for you to authorise access."; @@ -113,9 +108,6 @@ /* Twitter Deprecation Message */ "alert.message.twitter-deprecation-message" = "On February 1, 2023, Twitter announced the end of free access to the Twitter API, effective February 9.\n\nSince Twitter does not provide RSS feeds, we’ve had to use the Twitter API. Without free access to that API, we can’t read feeds from Twitter.\n\nWe’ve left your Twitter feeds intact. If you have any starred items from those feeds, they will remain as long as you don’t delete those feeds.\n\nYou can still read whatever you have already downloaded. However, those feeds will no longer update."; -/* Already subscribed */ -"alert.title.already-subscribed" = "Already subscribed"; - /* Author's website: */ "alert.title.authors-website" = "Author's website:"; @@ -143,9 +135,6 @@ /* Error */ "alert.title.error" = "Error"; -/* Feed not found */ -"alert.title.feed-not-found" = "Feed not found"; - /* Install theme “%@” by %@? — the order of the variables is theme name, author name */ "alert.title.install-theme.%@.%@" = "Install theme “%@” by %@?"; diff --git a/Mac/Resources/en.lproj/Localizable.strings b/Mac/Resources/en.lproj/Localizable.strings index 76dd21ede..7984a8d95 100644 --- a/Mac/Resources/en.lproj/Localizable.strings +++ b/Mac/Resources/en.lproj/Localizable.strings @@ -61,9 +61,6 @@ /* You won't see this message again */ "alert.informative.will-not-see-again" = "You won't see this message again"; -/* Can’t add this feed because you’ve already subscribed to it. */ -"alert.message.already-subscribed" = "Can’t add this feed because you’ve already subscribed to it."; - /* Some articles don’t have links, so they weren't copied. */ "alert.message.articles-without-links" = "Some articles don’t have links, so they weren't copied."; @@ -98,9 +95,6 @@ /* To enable notifications, open Notifications in System Settings, then find NetNewsWire in the list. */ "alert.message.enable-notifications-in-system-settings" = "To enable notifications, open Notifications in System Settings, then find NetNewsWire in the list."; -/* Can’t add a feed because no feed was found. */ -"alert.message.feed-not-found" = "Can’t add a feed because no feed was found."; - /* A web browser will open the Feedly login for you to authorize access. */ "alert.message.feedly-web-browser-information" = "A web browser will open the Feedly login for you to authorize access."; @@ -110,9 +104,6 @@ /* Twitter Deprecation Message */ "alert.message.twitter-deprecation-message" = "On February 1, 2023, Twitter announced the end of free access to the Twitter API, effective February 9.\n\nSince Twitter does not provide RSS feeds, we’ve had to use the Twitter API. Without free access to that API, we can’t read feeds from Twitter.\n\nWe’ve left your Twitter feeds intact. If you have any starred items from those feeds, they will remain as long as you don’t delete those feeds.\n\nYou can still read whatever you have already downloaded. However, those feeds will no longer update."; -/* Already subscribed */ -"alert.title.already-subscribed" = "Already subscribed"; - /* Author's website: */ "alert.title.authors-website" = "Author's website:"; @@ -140,9 +131,6 @@ /* Error */ "alert.title.error" = "Error"; -/* Feed not found */ -"alert.title.feed-not-found" = "Feed not found"; - /* Install theme “%@” by %@? — the order of the variables is theme name, author name */ "alert.title.install-theme.%@.%@" = "Install theme “%@” by %@?"; diff --git a/iOS/UIKit Extensions/UIViewController-Extensions.swift b/iOS/UIKit Extensions/UIViewController-Extensions.swift index 9bc533dd6..383225ff4 100644 --- a/iOS/UIKit Extensions/UIViewController-Extensions.swift +++ b/iOS/UIKit Extensions/UIViewController-Extensions.swift @@ -44,6 +44,8 @@ extension UIViewController { informativeText = error.localizedDescription presentError(title: errorTitle, message: informativeText, dismiss: dismiss) } + } else if let accountError = error as? AccountError { + presentError(title: accountError.errorTitle, message: accountError.localizedDescription) } else { let errorTitle = NSLocalizedString("alert.title.error", comment: "Error") presentError(title: errorTitle, message: error.localizedDescription, dismiss: dismiss)