Unifies account error localizations

This commit is contained in:
Stuart Breckenridge
2023-03-11 17:14:05 +08:00
parent 37cfba50a2
commit ceb925d0f9
8 changed files with 65 additions and 32 deletions

View File

@@ -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 couldnt be found and cant be added.", comment: "Not found")
// TODO: Add to Localizable
return NSLocalizedString("error.message.feed-not-found", bundle: Bundle.module, comment: "Cant add a feed because no feed was found.")
case .createErrorAlreadySubscribed:
return NSLocalizedString("You are already subscribed to this feed and cant 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 cant 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)
}

View File

@@ -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" = "Cant add a feed because no feed was found.";
"error.message.already-subscribed" = "You are already subscribed to this feed and cant add it again.";
"error.message.opml-import-in-progress" = "An OPML import for this account is already running.";

View File

@@ -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" = "Cant add a feed because no feed was found.";
"error.message.already-subscribed" = "You are already subscribed to this feed and cant add it again.";
"error.message.opml-import-in-progress" = "An OPML import for this account is already running.";