Localize strings in code
This commit is contained in:
parent
2d5ca58bd9
commit
1b4040135e
36 changed files with 626 additions and 334 deletions
|
|
@ -23,27 +23,6 @@ public enum AppError: Error {
|
|||
|
||||
extension AppError: LocalizedError {
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case .RepositoryNotSetError:
|
||||
return "Git repository is not set."
|
||||
case let .RepositoryRemoteBranchNotFoundError(remoteBranchName):
|
||||
return "Cannot find remote branch 'origin/\(remoteBranchName)'."
|
||||
case let .RepositoryBranchNotFound(branchName):
|
||||
return "Branch with name '\(branchName)' not found in repository."
|
||||
case .KeyImportError:
|
||||
return "Cannot import the key."
|
||||
case .PasswordDuplicatedError:
|
||||
return "Cannot add the password: password duplicated."
|
||||
case .GitResetError:
|
||||
return "Cannot identify the latest synced commit."
|
||||
case .PGPPublicKeyNotExistError:
|
||||
return "PGP public key doesn't exist."
|
||||
case .WrongPasswordFilename:
|
||||
return "Cannot write to the password file."
|
||||
case .DecryptionError:
|
||||
return "Cannot decrypt password."
|
||||
case .UnknownError:
|
||||
return "Unknown error."
|
||||
}
|
||||
return String(describing: self).localize()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public extension FileManager {
|
|||
fileSize = try fileSize ?? resourceValueForKey(URLResourceKey.fileAllocatedSizeKey)
|
||||
|
||||
guard let size = fileSize else {
|
||||
preconditionFailure("huh? NSURLFileAllocatedSizeKey should always return a value")
|
||||
preconditionFailure("NSURLFileAllocatedSizeKeyShouldAlwaysReturnValue.".localize())
|
||||
}
|
||||
|
||||
// We're good, add up the value.
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class Utils {
|
|||
|
||||
public static func alert(title: String, message: String, controller: UIViewController, handler: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) {
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: handler))
|
||||
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: handler))
|
||||
controller.present(alert, animated: true, completion: completion)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue