Prepare for localization

This commit is contained in:
Danny Moesch 2019-01-14 20:55:19 +01:00 committed by Mingshen Sun
parent 88481ad2b0
commit 857a8f44bf
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,25 @@
/*
String.swift
passKit
Created by Danny Moesch on 12.01.19.
Copyright © 2019 Bob Sun. All rights reserved.
*/
extension String {
public func localize() -> String {
return NSLocalizedString(self, value: "#\(self)#", comment: "")
}
public func localize(_ firstValue: CVarArg) -> String {
return String(format: localize(), firstValue)
}
public func localize(_ firstValue: CVarArg, _ secondValue: CVarArg) -> String {
return String(format: localize(), firstValue, secondValue)
}
public func localize(_ error: Error) -> String {
return localize(error.localizedDescription)
}
}