Ver código fonte

语言切换逻辑

桂欢 1 ano atrás
pai
commit
e0aba2b858

+ 1 - 1
SLAiELTS/SLAiELTS/Tool/SDPhotoBrowser/SDPhotoBrowser.m

@@ -83,7 +83,7 @@
     
     // 2.保存按钮
     UIButton *saveButton = [[UIButton alloc] init];
-    [saveButton setTitle:NSLocalizedString(NSLocalizedString(@"保存  ", nil), nil) forState:UIControlStateNormal];
+    [saveButton setTitle:NSLocalizedString(@"保存  ", nil) forState:UIControlStateNormal];
     [saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
     saveButton.backgroundColor = [UIColor colorWithRed:0.1f green:0.1f blue:0.1f alpha:0.90f];
     saveButton.layer.cornerRadius = 5;

+ 1 - 1
SLAiELTS/SLAiELTS/Tool/Views/SLDatePickView.m

@@ -196,7 +196,7 @@
 {
     if (!_sureBtn) {
         _sureBtn = [UIButton buttonWithType:UIButtonTypeSystem];
-        [_sureBtn setTitle:NSLocalizedString(NSLocalizedString(@"保存  ", nil), nil) forState:UIControlStateNormal];
+        [_sureBtn setTitle:NSLocalizedString(@"保存  ", nil) forState:UIControlStateNormal];
         _sureBtn.titleLabel.font = [UIFont systemFontOfSize:15];
         [_sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
         [self.toolView addSubview:_sureBtn];

+ 1 - 1
SLAiELTS/SLAiELTS/Tool/Views/SLPickView.m

@@ -240,7 +240,7 @@
 {
     if (!_sureBtn) {
         _sureBtn = [UIButton buttonWithType:UIButtonTypeSystem];
-        [_sureBtn setTitle:NSLocalizedString(NSLocalizedString(@"保存  ", nil), nil) forState:UIControlStateNormal];
+        [_sureBtn setTitle:NSLocalizedString(@"保存  ", nil) forState:UIControlStateNormal];
         _sureBtn.titleLabel.font = [UIFont systemFontOfSize:15];
         [_sureBtn addTarget:self action:@selector(sureBtnClick) forControlEvents:UIControlEventTouchUpInside];
         [self.toolView addSubview:_sureBtn];

+ 1 - 1
SLAiELTS/SLAiELTS/ViewControllers/FriendsVC/SLRecomFriendsVc.m

@@ -33,7 +33,7 @@
     [self.tableView registerNibCellWithReuseIdentifierClass:SLRecomFriendsCell.class];
     self.topConst.constant = kNavBarHeight;
     self.navigationBar.separatorHeight = 0.0f;
-    self.title = NSLocalizedString(NSLocalizedString(@"推荐好友", nil), nil);
+    self.title = NSLocalizedString(@"推荐好友", nil);
     [self requestData];
 }
 

+ 19 - 27
SLAiELTS/SLAiELTS/ViewControllers/MyVC/VCs/SLMsgBgSetVc.m

@@ -59,34 +59,26 @@
             [self.imageUpload addPicWithPhotoLibrary];
         }
     }
-    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
-    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
-        return;
-    }
-    for (UITableViewCell *acell in tableView.visibleCells) {
-        acell.accessoryType = acell == cell ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
-    }
-    if (indexPath.row == 0) {
-        [DAConfig setUserLanguage:@"zh-Hans"];
-    } else if (indexPath.row == 1) {
-        [DAConfig setUserLanguage:@"en"];
-    } else {
-        [DAConfig setUserLanguage:nil];
-
+    SLPageModelDetail *detail = [[self.dataModels objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
+    if ([detail.title isEqualToString:@"简体中文"] || [detail.title isEqualToString:@"English"]) {
+        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+        if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
+            return;
+        }
+        for (UITableViewCell *acell in tableView.visibleCells) {
+            acell.accessoryType = acell == cell ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+        }
+        if (indexPath.row == 0) {
+            [DAConfig setUserLanguage:@"zh-Hans"];
+        } else if (indexPath.row == 1) {
+            [DAConfig setUserLanguage:@"en"];
+        } else {
+            [DAConfig setUserLanguage:nil];
+        }
+        //更新当前
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        [appDelegate setTabWithRootWindow];
     }
-    //更新当前storyboard
-//    UITabBarController *tbc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
-//    tbc.selectedIndex = 2;
-//    DALanguageSettingsViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([DALanguageSettingsViewController class])];
-//    UINavigationController *nvc = tbc.selectedViewController;
-//    NSMutableArray *vcs = nvc.viewControllers.mutableCopy;
-//    [vcs addObject:vc];
-    //解决奇怪的动画bug。异步执行
-//    dispatch_async(dispatch_get_main_queue(), ^{
-//        [UIApplication sharedApplication].keyWindow.rootViewController = tbc;
-//        nvc.viewControllers = vcs;
-//        NSLog(@"已切换到语言 %@", [NSBundle currentLanguage]);
-//    });
     
 }
 

+ 2 - 2
SLAiELTS/SLAiELTS/ViewControllers/MyVC/VCs/SLUserCenterViewController.m

@@ -126,7 +126,7 @@
         SLMsgBgSetVc *vc = [SLMsgBgSetVc loadViewControllewWithNib];
         [self navPushViewController:vc animated:YES];
     }
-    if ([detail.title isEqualToString:NSLocalizedString(NSLocalizedString(@"语言设置", nil), nil)]) {
+    if ([detail.title isEqualToString:NSLocalizedString(@"语言设置", nil)]) {
         SLMsgBgSetVc *vc = [SLMsgBgSetVc loadViewControllewWithNib];
         [self navPushViewController:vc animated:YES];
         NSArray *arr = @[
@@ -177,7 +177,7 @@
           @[[SLPageModelDetail initWithTitle:NSLocalizedString(@"退出登录", nil) subTitle:@"" bgImage:@""],]];
         if (self.isSetting) {
             arr = @[
-                  @[[SLPageModelDetail initWithTitle:NSLocalizedString(NSLocalizedString(@"语言设置", nil), nil) subTitle:@"" bgImage:@""],
+                  @[[SLPageModelDetail initWithTitle:NSLocalizedString(@"语言设置", nil) subTitle:@"" bgImage:@""],
                     [SLPageModelDetail initWithTitle:NSLocalizedString(@"聊天背景", nil) subTitle:@"" bgImage:@""]],
                   @[[SLPageModelDetail initWithTitle:NSLocalizedString(@"清空聊天记录", nil) subTitle:@"" bgImage:@""],]];
         }