mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Localization work
This commit is contained in:
@@ -14,20 +14,20 @@ extension UIViewController {
|
||||
|
||||
func presentError(_ error: Error, dismiss: (() -> Void)? = nil) {
|
||||
if let decodingError = error as? DecodingError {
|
||||
let errorTitle = NSLocalizedString("Error", comment: "Error")
|
||||
let errorTitle = NSLocalizedString("alert.title.error", comment: "Error")
|
||||
var informativeText: String = ""
|
||||
switch decodingError {
|
||||
case .typeMismatch(let type, _):
|
||||
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
|
||||
let localizedError = NSLocalizedString("alert.message.theme-type-mismatch.%@", comment: "Error message when a type is mismatched. In English, the message is: This theme cannot be used because the the type—“%@”—is mismatched in the Info.plist.")
|
||||
informativeText = String.localizedStringWithFormat(localizedError, type as! CVarArg)
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
case .valueNotFound(let value, _):
|
||||
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
|
||||
let localizedError = NSLocalizedString("alert.message.theme-value-missing.%@", comment: "Error message when a value is missing. In English, the message is: This theme cannot be used because the the value—“%@”—is not found in the Info.plist.")
|
||||
informativeText = String.localizedStringWithFormat(localizedError, value as! CVarArg)
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
case .keyNotFound(let codingKey, _):
|
||||
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
|
||||
let localizedError = NSLocalizedString("alert.message.theme-key-missing.%@", comment: "Error message when a key is missing. In English, the message is: This theme cannot be used because the the key—“%@”—is not found in the Info.plist.")
|
||||
informativeText = String.localizedStringWithFormat(localizedError, codingKey.stringValue)
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
case .dataCorrupted(let context):
|
||||
guard let error = context.underlyingError as NSError?,
|
||||
@@ -36,7 +36,7 @@ extension UIViewController {
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
return
|
||||
}
|
||||
let localizedError = NSLocalizedString("This theme cannot be used because of data corruption in the Info.plist. %@.", comment: "Decoding key missing")
|
||||
let localizedError = NSLocalizedString("alert.message.theme-data-corrupted.%@", comment: "Error message when theme data is corrupted. The variable is a description provided by Apple. In English, the message is: This theme cannot be used because of data corruption in the Info.plist. %@.")
|
||||
informativeText = NSString.localizedStringWithFormat(localizedError as NSString, debugDescription) as String
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
|
||||
@@ -45,7 +45,7 @@ extension UIViewController {
|
||||
presentError(title: errorTitle, message: informativeText, dismiss: dismiss)
|
||||
}
|
||||
} else {
|
||||
let errorTitle = NSLocalizedString("Error", comment: "Error")
|
||||
let errorTitle = NSLocalizedString("alert.title.error", comment: "Error")
|
||||
presentError(title: errorTitle, message: error.localizedDescription, dismiss: dismiss)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user