Browse Source

添加国际化所使用的文件 和方法

jsonwang 3 years ago
parent
commit
d28c42f2f2

+ 12 - 0
BFCommonKit/Assets/Base.lproj/Localizable.strings

@@ -0,0 +1,12 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/
+
+"home_msg_welcome" = "Welcome to DubDub";
+
+
+ 

+ 12 - 0
BFCommonKit/Assets/en.lproj/Localizable.strings

@@ -0,0 +1,12 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/
+
+"home_msg_welcome" = "Welcome to DubDub";
+
+
+ 

+ 7 - 0
BFCommonKit/Assets/id.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/

+ 7 - 0
BFCommonKit/Assets/ja.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/

+ 7 - 0
BFCommonKit/Assets/ko-KR.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/

+ 7 - 0
BFCommonKit/Assets/ru.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/

+ 7 - 0
BFCommonKit/Assets/vi.lproj/Localizable.strings

@@ -0,0 +1,7 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/

+ 9 - 0
BFCommonKit/Assets/zh-Hans.lproj/Localizable.strings

@@ -0,0 +1,9 @@
+/* 
+  Localizble.strings
+  Introduce
+
+  Created by ak on 2022/1/17.
+  Copyright © 2022 BytesFlow. All rights reserved.
+*/
+"home_msg_welcome" = "环境使用";
+

+ 19 - 0
BFCommonKit/Classes/BFCategorys/BFString+Ext.swift

@@ -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
+    }
+}
+
+