Browse Source

1【IOS端】IOS端云机推流里面的悬浮按钮 外语问题修复

huangxiaodong 3 months ago
parent
commit
7180c07fc4

+ 65 - 24
创维盒子/code/CloudPlayer/View/playerSetView.m

@@ -79,29 +79,47 @@
     CGFloat laberH = 16.0;
     
     //延迟
-    UILabel * delayedTipLabel =  [[UILabel alloc] init];
-    delayedTipLabel.font = [UIFont systemFontOfSize:12.0];
-    delayedTipLabel.textColor = [UIColor whiteColor];
-    delayedTipLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
-    [_blackBgView addSubview:delayedTipLabel];
-    //delayedTipLabel.backgroundColor = [UIColor redColor];
-    
-    [delayedTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(15);
-        make.width.mas_equalTo(laberW);
-        make.height.mas_equalTo(laberH);
-        make.top.mas_equalTo(laberTop);
-    }];
+//    UILabel * delayedTipLabel =  [[UILabel alloc] init];
+//    delayedTipLabel.font = [UIFont systemFontOfSize:12.0];
+//    delayedTipLabel.textColor = [UIColor whiteColor];
+//    delayedTipLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
+//    [_blackBgView addSubview:delayedTipLabel];
+//    //delayedTipLabel.backgroundColor = [UIColor redColor];
+//    
+//    [delayedTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.left.mas_equalTo(15);
+//        make.width.mas_equalTo(laberW);
+//        make.height.mas_equalTo(laberH);
+//        make.top.mas_equalTo(laberTop);
+//    }];
+    
+    CGFloat fontSize = 12.0;
+    
+    ///获取设备当前地区的代码和APP语言环境
+    NSString *languageCode = [NSLocale preferredLanguages][0];
+
+    BOOL isForeignType = NO;
+    //目前支持 中文(简体 繁体) 英文 日语
+    if([languageCode rangeOfString:@"zh-Hans"].location != NSNotFound)
+    {
+    }
+    else if([languageCode rangeOfString:@"zh-Hant"].location != NSNotFound)
+    {
+    }
+    else{
+        isForeignType = YES;
+        fontSize = 10.5;
+    }
     
     _delayedLabel =  [[UILabel alloc] init];
-    _delayedLabel.font = [UIFont systemFontOfSize:12.0];
+    _delayedLabel.font = [UIFont systemFontOfSize:fontSize];
     //_delayedLabel.textColor = [UIColor whiteColor];
     //_delayedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
     [_blackBgView addSubview:_delayedLabel];
     //_delayedLabel.backgroundColor = [UIColor redColor];
     
     [_delayedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(delayedTipLabel.mas_right).offset(0);
+        make.left.mas_equalTo(15);
         //make.width.mas_equalTo(laberW+5);
         make.height.mas_equalTo(laberH);
         make.top.mas_equalTo(laberTop);
@@ -123,7 +141,7 @@
 //    }];
 //    
     _PacketLossLabel =  [[UILabel alloc] init];
-    _PacketLossLabel.font = [UIFont systemFontOfSize:12.0];
+    _PacketLossLabel.font = [UIFont systemFontOfSize:fontSize];
     _PacketLossLabel.textAlignment = NSTextAlignmentCenter;
     _PacketLossLabel.textColor = [UIColor whiteColor];//[UIColor hwColor:@"#FF2855"];
     //_PacketLossLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
@@ -133,7 +151,7 @@
     [_PacketLossLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         //make.left.mas_equalTo(PacketLossTipLabel.mas_right).offset(0);
         make.centerX.mas_equalTo(self.mas_centerX);
-        make.width.mas_equalTo(laberW*3.0);
+        //make.width.mas_equalTo(laberW*3.0);
         make.height.mas_equalTo(laberH);
         make.top.mas_equalTo(laberTop);
     }];
@@ -154,7 +172,7 @@
 //    }];
     
     _speedLabel =  [[UILabel alloc] init];
-    _speedLabel.font = [UIFont systemFontOfSize:12.0];
+    _speedLabel.font = [UIFont systemFontOfSize:fontSize];
     _speedLabel.textColor = [UIColor whiteColor];
     _speedLabel.textAlignment = NSTextAlignmentRight;
     //_speedLabel.text = NSLocalizedString(@"webrtc_msg_delayed",nil);
@@ -165,7 +183,7 @@
         //make.centerX.mas_equalTo(1.5*laberW);
         //make.centerX.mas_equalTo(self.mas_centerX);
         make.right.mas_equalTo(-15);
-        make.width.mas_equalTo(laberW*3.0);
+        //make.width.mas_equalTo(laberW*3.0);
         make.height.mas_equalTo(laberH);
         make.top.mas_equalTo(laberTop);
     }];
@@ -438,11 +456,16 @@
             make.top.mas_equalTo(0);
         }];
         
+        NSString *curText = titleArr[i];
+        if(isForeignType && i==2){
+            curText = [curText stringByReplacingOccurrencesOfString:@" cloudPhone" withString:@""];
+        }
+        
         UILabel *textLabel = [[UILabel alloc] init];
         textLabel.textAlignment = NSTextAlignmentCenter;
-        textLabel.font = [UIFont systemFontOfSize:12.0];
+        textLabel.font = [UIFont systemFontOfSize:12];
         textLabel.textColor = [UIColor whiteColor];
-        textLabel.text = titleArr[i];
+        textLabel.text = curText;
         [but addSubview:textLabel];
         //textLabel.backgroundColor = [UIColor redColor];
         
@@ -594,10 +617,28 @@
         _delayedLabel.text = [[NSString alloc] initWithFormat:@"%ldms",delayedMS];
     }
     
+    NSString * delayedStr = @"";
+    if(delayedMS >= 1000){
+        delayedStr = [[NSString alloc] initWithFormat:@"%lds",delayedMS/1000];
+    }
+    else{
+        delayedStr = [[NSString alloc] initWithFormat:@"%ldms",delayedMS];
+    }
+    
+    NSString*leftStr = NSLocalizedString(@"webrtc_msg_delayed",nil);
+    
+    NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@",leftStr,delayedStr];
+    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
+
+    NSRange leftRange = NSMakeRange([fullTitle rangeOfString:leftStr].location, [fullTitle rangeOfString:leftStr].length);
+    [attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:leftRange];
+
+    _delayedLabel.attributedText = attrStr;
+    
     NSString*LossleftStr = NSLocalizedString(@"webrtc_msg_PacketLoss",nil);
     NSString*LossRightStr  = [[NSString alloc] initWithFormat:@"%.02f%%",PacketLoss];
     NSString *LossfullTitle = [[NSString alloc] initWithFormat:@"%@%@",LossleftStr,LossRightStr];
-    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:LossfullTitle];
+    NSMutableAttributedString *attrStr2 = [[NSMutableAttributedString alloc] initWithString:LossfullTitle];
     NSRange rightRange = NSMakeRange([LossfullTitle rangeOfString:LossRightStr].location, LossRightStr.length);
     UIColor *rightColor = [UIColor hwColor:@"22A082"];
     if(PacketLoss >= 5 && PacketLoss < 10){
@@ -607,8 +648,8 @@
         rightColor = [UIColor hwColor:@"#FF2855"];
     }
     
-    [attrStr addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
-    _PacketLossLabel.attributedText = attrStr;
+    [attrStr2 addAttribute:NSForegroundColorAttributeName value:rightColor range:rightRange];
+    _PacketLossLabel.attributedText = attrStr2;
     
     _speedLabel.text = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"webrtc_msg_speed",nil),speedStr];
     //_fpsLabel.text = [[NSString alloc] initWithFormat:@"FPS:%@",fpsStr];

+ 3 - 3
创维盒子/code/en.lproj/Localizable.strings

@@ -572,7 +572,7 @@
 
 "cloudPhone_enter_tip"   = "Enter Cloud Phone";
 "cloudPhone_upload_app"   = "Application Upload";
-"cloudPhone_nav_show_tip"   = "Navigation Bar";
+"cloudPhone_nav_show_tip"   = "Nav Bar";
 "cloudPhone_fullScreen_show_tip"   = "Full Screen";
 "cloudPhone_set_exit_tip"   = "Exit Cloud Machine";
 "cloudPhone_set_screenshot_tip"   = "Screenshot";
@@ -629,8 +629,8 @@
 "common_wwan_open_tip"   = "Go to Open";
 "no_wifi_warn_tip"   = "Currently in a non-WIFI environment. To transfer files via data, please enable data transfer in settings.";
 "shortcatRep_tip"   = "Screenshot saved to cloud directory under control";
-"webrtc_msg_delayed"   = "Latency:";
-"webrtc_msg_PacketLoss"   = "Packet Loss:";
+"webrtc_msg_delayed"   = "Delay:";
+"webrtc_msg_PacketLoss"   = "Loss rate:";
 "webrtc_msg_speed"   = "Bandwidth:";
 "app_version_current"   = "Current APP Version";
 "system_version_current"   = "Current System Version";