2020-09-20 13:46:54 +02:00
|
|
|
//
|
|
|
|
|
// String+Localization.swift
|
|
|
|
|
// passKit
|
|
|
|
|
//
|
|
|
|
|
// Created by Danny Moesch on 12.01.19.
|
|
|
|
|
// Copyright © 2019 Bob Sun. All rights reserved.
|
|
|
|
|
//
|
2019-01-14 20:55:19 +01:00
|
|
|
|
|
|
|
|
extension String {
|
|
|
|
|
public func localize() -> String {
|
2020-07-05 00:45:31 +02:00
|
|
|
// swiftlint:disable:next nslocalizedstring_key
|
2020-07-05 00:49:01 +02:00
|
|
|
NSLocalizedString(self, bundle: Bundle.main, value: "#\(self)#", comment: "")
|
2019-01-14 20:55:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func localize(_ firstValue: CVarArg) -> String {
|
2020-06-28 21:25:40 +02:00
|
|
|
String(format: localize(), firstValue)
|
2019-01-14 20:55:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func localize(_ firstValue: CVarArg, _ secondValue: CVarArg) -> String {
|
2020-06-28 21:25:40 +02:00
|
|
|
String(format: localize(), firstValue, secondValue)
|
2019-01-14 20:55:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func localize(_ error: Error) -> String {
|
2020-06-28 21:25:40 +02:00
|
|
|
localize(error.localizedDescription)
|
2019-01-14 20:55:19 +01:00
|
|
|
}
|
|
|
|
|
}
|