浏览代码

1,国际化文字 2,国际翻译 APP key

jsonwang 3 年之前
父节点
当前提交
7c38da8ffa

+ 4 - 4
BFRecordScreenKit/Classes/BFRecordExport.swift

@@ -300,7 +300,7 @@ public class BFRecordExport {
         BFLog(1, message: "导出视频地址 \(outPutMP4URL)")
 
         guard let itemData = data else {
-            let error = NSError(domain: "err", code: ExportError.DataLost.rawValue, userInfo: ["msg": "所有数据丢失"])
+            let error = NSError(domain: "err", code: ExportError.DataLost.rawValue, userInfo: ["msg": "compose_fail_lost".BFLocale])
             exportCompletion?(error as Error, nil)
             return
         }
@@ -397,15 +397,15 @@ public class BFRecordExport {
                     let exportEndTime = Date().timeIntervalSince1970
                     BFLog(1, message: "生成视频时长为:\(outSeconds) 总用时:\(exportEndTime - tempBeginExport)")
                     if(PQENVUtil.shared.channel == "Development"){
-                        cShowHUB(superView: nil, msg: (outSeconds == 0) ? "合成失败请重试。" : String(format: "总用时: %.2f", exportEndTime - tempBeginExport))
+                        cShowHUB(superView: nil, msg: (outSeconds == 0) ? "compose_retry3".BFLocale : String(format: "总用时: %.2f", exportEndTime - tempBeginExport))
                     }
 
                     self?.exportCompletion?(nil, url)
 
                 } else {
-                    let error = NSError(domain: "err", code: ExportError.ExportExcept.rawValue, userInfo: ["msg": "导出异常失败"])
+                    let error = NSError(domain: "err", code: ExportError.ExportExcept.rawValue, userInfo: ["msg": "compose_fail_export".BFLocale])
                     self?.exportCompletion?(error as Error, nil)
-                    cShowHUB(superView: nil, msg: "导出失败")
+                    cShowHUB(superView: nil, msg: "compose_fail_export".BFLocale)
                 }
 
                 // 导出完成后取消导出

+ 8 - 9
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -52,8 +52,7 @@ public class BFRecordScreenController: BFBaseViewController {
             changeVoiceBtn.isHidden = isRecording
             subtitleBtn.isHidden = isRecording
             soundSettingBtn.isHidden = isRecording
-
-            recordBtn.setTitle(isRecording ? "松手 暂停" : "按住 录音", for: .normal)
+            recordBtn.setTitle(isRecording ? "record_pause".BFLocale : "record_ly".BFLocale, for: .normal)
             recordBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF", alpha: isRecording ? 0.6 : 1)
 //            if !isRecording {
 //                BFLog(1, message: "stop")
@@ -186,7 +185,7 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var recordBtn: UIButton = {
         let btn = UIButton(type: .custom)
         btn.backgroundColor = ThemeStyleColor
-        btn.setTitle("按住 录音", for: .normal)
+        btn.setTitle("record_ly".BFLocale, for: .normal)
         btn.addCorner(corner: 6)
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.adjustsImageWhenHighlighted = false
@@ -200,7 +199,7 @@ public class BFRecordScreenController: BFBaseViewController {
         let btn = UIButton(type: .custom)
 
         btn.backgroundColor = UIColor.hexColor(hexadecimal: "#FF0000", alpha: 0.3)
-        btn.setTitle("删除录制", for: .normal)
+        btn.setTitle("record_delete".BFLocale, for: .normal)
         btn.adjustsImageWhenHighlighted = false
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
         btn.addCorner(corner: 6)
@@ -213,7 +212,7 @@ public class BFRecordScreenController: BFBaseViewController {
         let btn = UIButton(type: .custom)
         btn.setImage(imageInRecordScreenKit(by: "withdraw_n"), for: .normal)
         btn.setImage(imageInRecordScreenKit(by: "withdraw_h"), for: .highlighted)
-        btn.setTitle("回退", for: .normal)
+        btn.setTitle("record_back".BFLocale, for: .normal)
         btn.setTitleColor(.white, for: .normal)
         btn.setTitleColor(.lightGray, for: .disabled)
         btn.isEnabled = false
@@ -1481,11 +1480,11 @@ public class BFRecordScreenController: BFBaseViewController {
             BFLog(message: "麦克风权限被拒绝,请在设置中打开")
             if show {
                 let remindData = BFBaseModel()
-                remindData.title = "需要开启「麦克风权限」才可以进行录制"
+                remindData.title = "grant_micpass".BFLocale
                 remindData.summary = ""
                 let remindView = BFRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
                 remindView.isBanned = true
-                remindView.confirmBtn.setTitle("去开启", for: .normal)
+                remindView.confirmBtn.setTitle("grant_open".BFLocale, for: .normal)
                 remindView.confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#389AFF"), for: .normal)
                 UIApplication.shared.keyWindow?.addSubview(remindView)
                 remindView.remindData = remindData
@@ -1937,9 +1936,9 @@ public class BFRecordScreenController: BFBaseViewController {
         case 3:
             withDrawBtn.setTitle("撤销删除", for: .normal)
         case 2:
-            withDrawBtn.setTitle("撤销录制", for: .normal)
+            withDrawBtn.setTitle("record_undo".BFLocale, for: .normal)
         default:
-            withDrawBtn.setTitle("回退", for: .normal)
+            withDrawBtn.setTitle("record_back".BFLocale, for: .normal)
         }
         withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width)
         withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0)

+ 2 - 2
BFRecordScreenKit/Classes/RecordScreen/View/BFAudioSettingView.swift

@@ -22,7 +22,7 @@ class BFAudioSettingView: UIView {
         let haveSpeakLab = UILabel()
         haveSpeakLab.font = UIFont.boldSystemFont(ofSize: 16)
         haveSpeakLab.textAlignment = .left
-        haveSpeakLab.text = "录音时 视频原声"
+        haveSpeakLab.text = "sound_record_ture".BFLocale
         haveSpeakLab.textColor = .white
         haveSpeakLab.backgroundColor = .clear
         return haveSpeakLab
@@ -59,7 +59,7 @@ class BFAudioSettingView: UIView {
         let noSpeakLab = UILabel()
         noSpeakLab.font = UIFont.boldSystemFont(ofSize: 16)
         noSpeakLab.textAlignment = .left
-        noSpeakLab.text = "未录音时 视频原声"
+        noSpeakLab.text = "sound_record_false".BFLocale
         noSpeakLab.textColor = .white
         return noSpeakLab
     }()

+ 3 - 3
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleEditView.swift

@@ -60,7 +60,7 @@ class BFSubtitleEditView: UIView {
 
         let doneBtn = UIButton()
         doneBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF")
-        doneBtn.setTitle("完成", for: .normal)
+        doneBtn.setTitle("option_done".BFLocale, for: .normal)
         doneBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
         doneBtn.addTarget(self, action: #selector(doneAction), for: .touchUpInside)
         doneBtn.addCorner(corner: 4)
@@ -74,7 +74,7 @@ class BFSubtitleEditView: UIView {
 
         let cancelBtn = UIButton()
         cancelBtn.backgroundColor = .clear
-        cancelBtn.setTitle("取消", for: .normal)
+        cancelBtn.setTitle("option_cancel".BFLocale, for: .normal)
         cancelBtn.setTitleColor(.white, for: .normal)
         cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
         cancelBtn.addTarget(self, action: #selector(cancelAction), for: .touchUpInside)
@@ -120,7 +120,7 @@ extension BFSubtitleEditView: UITextViewDelegate {
 
     func textView(_: UITextView, shouldChangeTextIn _: NSRange, replacementText text: String) -> Bool {
         if text.isEmoji() {
-            cShowHUB(superView: nil, msg: "不能输入表情")
+            cShowHUB(superView: nil, msg: "option_fail_emoji".BFLocale)
             return false
         }
  

+ 6 - 6
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -90,7 +90,7 @@ class BFSubtitleSettingView: UIView {
         pointTitle.textAlignment = .center
         pointTitle.font = UIFont.systemFont(ofSize: 15)
         pointTitle.textColor = .white
-        pointTitle.text = "位置"
+        pointTitle.text = "option_location".BFLocale
         pointTitle.alpha = 0.6
         backView.addSubview(pointTitle)
         pointTitle.snp.makeConstraints { make in
@@ -110,11 +110,11 @@ class BFSubtitleSettingView: UIView {
                 pointBtn.layer.borderColor = UIColor.hexColor(hexadecimal: "#389AFF").cgColor
                 pointBtn.layer.borderWidth = 1.5
                 lastSelectPointBtn = pointBtn
-                pointBtn.setTitle("下", for: .normal)
+                pointBtn.setTitle("option_bottom".BFLocale, for: .normal)
             } else if i == 1 {
-                pointBtn.setTitle("中", for: .normal)
+                pointBtn.setTitle("option_middle".BFLocale, for: .normal)
             } else {
-                pointBtn.setTitle("上", for: .normal)
+                pointBtn.setTitle("option_top".BFLocale, for: .normal)
             }
             pointBtn.addCorner(corner: 10)
             pointBtn.tag = i
@@ -133,7 +133,7 @@ class BFSubtitleSettingView: UIView {
         wordSizeTitle.textAlignment = .center
         wordSizeTitle.font = UIFont.systemFont(ofSize: 15)
         wordSizeTitle.textColor = .white
-        wordSizeTitle.text = "字号"
+        wordSizeTitle.text = "option_size".BFLocale
         wordSizeTitle.alpha = 0.6
         backView.addSubview(wordSizeTitle)
         wordSizeTitle.snp.makeConstraints { make in
@@ -185,7 +185,7 @@ class BFSubtitleSettingView: UIView {
         disabelTitle.textAlignment = .left
         disabelTitle.font = UIFont.boldSystemFont(ofSize: 17)
         disabelTitle.textColor = .white
-        disabelTitle.text = "关闭字幕"
+        disabelTitle.text = "option_off".BFLocale
         backView.addSubview(disabelTitle)
         disabelTitle.snp.makeConstraints { make in
             make.width.equalTo(100)

+ 10 - 8
BFRecordScreenKit/Classes/RecordScreen/ViewModel/BFRecordScreenViewModel.swift

@@ -16,25 +16,27 @@ public class BFRecordScreenViewModel: NSObject {
     /// 取文本转语言 token
     /// - Parameter completeHander: <#completeHander description#>
     public class func getNlsAccessToken(completeHander: @escaping (_ token: String, _ appkey: String) -> Void) {
-        let NlsAccessTokenKey: String = "NlsAccessTokenKey_JiangjieApp"
-
+   
+        let currentLanguage =  BFLocalizedUtil.currentLanguage()
+        BFLog(2,message: "当前的系统语言是:\(currentLanguage)")
         let nowTime: TimeInterval = Date().timeIntervalSince1970
-
-        //        token = "5d96258dcea34d7b91576031cd25a9ba"; 返回数据
-        //        expireTime = 1601376826000; //1601377050000;
-        let saveToken: Dictionary? = getUserDefaults(key: NlsAccessTokenKey) as? [String: Any] ?? nil
+        //token = "5d96258dcea34d7b91576031cd25a9ba"; 返回数据
+        //expireTime = 1601376826000; //1601377050000;
+        let saveToken: Dictionary? = getUserDefaults(key: currentLanguage) as? [String: Any] ?? nil
         if saveToken != nil && Double(saveToken!["expireTime"] as! Double) > nowTime * 1000 {
             BFLog(message: "nls token 还有效期内不用重新请求 \(String(describing: saveToken!["expireTime"])) nowTime:\(nowTime * 1000)")
             completeHander(saveToken!["token"] as! String, saveToken!["appkey"] as! String)
             return
         }
-        BFNetRequestAdaptor.getRequestData(url: PQENVUtil.shared.clipapiapi + getNlsAccessTokenForJiangjieApp, parames: nil, commonParams: commonParams()) { response, _, _, _ in
+        
+  
+        BFNetRequestAdaptor.getRequestData(url: PQENVUtil.shared.clipapiapi + getNlsAccessTokenForJiangjieApp, parames: ["languageCode":currentLanguage], commonParams: commonParams()) { response, _, _, _ in
 
             if let response = response as? [String: Any], let token = response["token"] as? String, let appkey = response["appkey"] as? String {
                 let nowTime: TimeInterval = Date().timeIntervalSince1970
 
                 BFLog(message: "nowTime is \(nowTime) token is \(token)")
-                saveUserDefaults(key: NlsAccessTokenKey, value: response)
+                saveUserDefaults(key: currentLanguage, value: response)
 
                 completeHander(token, appkey)
             } else {