|
@@ -200,3 +200,22 @@ public extension Optional where Wrapped == String {
|
|
|
return self?.isSpace ?? true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+// add by ak 本地化 e.g. "home_msg_welcome".BFLocale
|
|
|
+public extension String{
|
|
|
+ class BFLocaleClass {}
|
|
|
+ var BFLocale: String {
|
|
|
+ let noFindStr = "key is not found!"
|
|
|
+ let bundlePaths = Bundle(for: BFLocaleClass.self).paths(forResourcesOfType: "bundle", inDirectory: nil)
|
|
|
+ guard bundlePaths.count > 0 , let resourcePath = (bundlePaths.first) else {
|
|
|
+ return noFindStr
|
|
|
+ }
|
|
|
+ let resourceBundle = Bundle(path: resourcePath)
|
|
|
+
|
|
|
+ let msg = NSLocalizedString(self, tableName: nil, bundle: resourceBundle!, value: noFindStr, comment: "")
|
|
|
+ return msg
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|