mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Localized strings for errors
This commit is contained in:
parent
709d163e9c
commit
25f9896832
@ -910,13 +910,13 @@ internal extension AppDelegate {
|
||||
alert.informativeText = NSString.localizedStringWithFormat(localizedInformativeText as NSString, themeName) as String
|
||||
|
||||
alert.addButton(withTitle: NSLocalizedString("OK", comment: "OK"))
|
||||
|
||||
alert.beginSheetModal(for: window)
|
||||
}
|
||||
|
||||
@objc func themeImportError(_ note: Notification) {
|
||||
guard let userInfo = note.userInfo,
|
||||
let error = userInfo["error"] as? Error,
|
||||
let window = mainWindowController?.window else {
|
||||
let error = userInfo["error"] as? Error else {
|
||||
return
|
||||
}
|
||||
themeImportPath = userInfo["path"] as? String
|
||||
@ -924,13 +924,23 @@ internal extension AppDelegate {
|
||||
if let decodingError = error as? DecodingError {
|
||||
switch decodingError {
|
||||
case .typeMismatch(let type, _):
|
||||
informativeText = "the type—'\(type)'—is mismatched."
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the type—“%@”—is mismatched in the Info.plist", comment: "Type mismatch")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, type as! CVarArg) as String
|
||||
case .valueNotFound(let value, _):
|
||||
informativeText = "the value—'\(value)'—is missing in the Info.plist."
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the value—“%@”—is not found in the Info.plist.", comment: "Decoding value missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, value as! CVarArg) as String
|
||||
case .keyNotFound(let codingKey, _):
|
||||
informativeText = "the key—'\(codingKey.stringValue)'—is missing in the Info.plist."
|
||||
case .dataCorrupted( _):
|
||||
informativeText = error.localizedDescription
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the key—“%@”—is not found in the Info.plist.", comment: "Decoding key missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, codingKey.stringValue) as String
|
||||
case .dataCorrupted(let context):
|
||||
guard let error = context.underlyingError as NSError?,
|
||||
let debugDescription = error.userInfo["NSDebugDescription"] as? String else {
|
||||
informativeText = error.localizedDescription
|
||||
break
|
||||
}
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because of data corruption in the Info.plist: %@.", comment: "Decoding key missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, debugDescription) as String
|
||||
|
||||
default:
|
||||
informativeText = error.localizedDescription
|
||||
}
|
||||
@ -942,14 +952,15 @@ internal extension AppDelegate {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .warning
|
||||
alert.messageText = NSLocalizedString("Theme Error", comment: "Theme download error")
|
||||
alert.informativeText = NSLocalizedString("This theme cannot be used because \(informativeText)", comment: "Theme download error information")
|
||||
alert.informativeText = informativeText
|
||||
alert.addButton(withTitle: NSLocalizedString("Open Theme Folder", comment: "Open Theme Folder"))
|
||||
alert.addButton(withTitle: NSLocalizedString("OK", comment: "OK"))
|
||||
|
||||
let button = alert.buttons.first
|
||||
button?.target = self
|
||||
button?.action = #selector(self.openThemesFolder(_:))
|
||||
|
||||
alert.buttons[0].keyEquivalent = "\033"
|
||||
alert.buttons[1].keyEquivalent = "\r"
|
||||
alert.runModal()
|
||||
}
|
||||
}
|
||||
|
@ -17,20 +17,34 @@ extension UIViewController {
|
||||
presentAccountError(accountError, dismiss: dismiss)
|
||||
} else if let decodingError = error as? DecodingError {
|
||||
let errorTitle = NSLocalizedString("Error", comment: "Error")
|
||||
let infromativeText: String = ""
|
||||
switch decodingError {
|
||||
case .typeMismatch(let type, _):
|
||||
let str = "This theme cannot be used because the type—'\(type)'—is mismatched in the Info.plist."
|
||||
presentError(title: errorTitle, message: str, dismiss: dismiss)
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the type—“%@”—is mismatched in the Info.plist", comment: "Type mismatch")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, type as! CVarArg) as String
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
case .valueNotFound(let value, _):
|
||||
let str = "This theme cannot be used because the value—'\(value)'—is missing in the Info.plist."
|
||||
presentError(title: errorTitle, message: str, dismiss: dismiss)
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the value—“%@”—is not found in the Info.plist.", comment: "Decoding value missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, value as! CVarArg) as String
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
case .keyNotFound(let codingKey, _):
|
||||
let str = "This theme cannot be used because the key—'\(codingKey.stringValue)'—is missing in the Info.plist."
|
||||
presentError(title: errorTitle, message: str, dismiss: dismiss)
|
||||
case .dataCorrupted( _):
|
||||
presentError(title: errorTitle, message: error.localizedDescription, dismiss: dismiss)
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because the the key—“%@”—is not found in the Info.plist.", comment: "Decoding key missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, codingKey.stringValue) as String
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
case .dataCorrupted(let context):
|
||||
guard let error = context.underlyingError as NSError?,
|
||||
let debugDescription = error.userInfo["NSDebugDescription"] as? String else {
|
||||
informativeText = error.localizedDescription
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
return
|
||||
}
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because of data corruption in the Info.plist. %@.", comment: "Decoding key missing")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, debugDescription) as String
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
|
||||
default:
|
||||
presentError(title: errorTitle, message: error.localizedDescription, dismiss: dismiss)
|
||||
informativeText = error.localizedDescription
|
||||
presentError(title: title, message: infromativeText, dismiss: dismiss)
|
||||
}
|
||||
} else {
|
||||
let errorTitle = NSLocalizedString("Error", comment: "Error")
|
||||
|
Loading…
Reference in New Issue
Block a user