From b2021dcb3c339fe2e1c5139fe713338cbed741a0 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Mon, 17 Nov 2025 21:35:25 +0800 Subject: [PATCH] 6 --- .../Localization/en.lproj/Localizable.strings | 17 ++++++++ .../zh-Hans.lproj/Localizable.strings | 22 ++++++++++ keyBoard/Class/Home/V/HomeHeadView.m | 2 +- .../Class/Home/VC/FunctionTest/KBLangTestVC.m | 41 +++++++++++++++++-- keyBoard/Class/Me/V/KBMyHeaderView.m | 4 +- keyBoard/Class/Me/VC/KBMyKeyBoardVC.m | 2 +- keyBoard/Class/Me/VC/MyVC.m | 12 +++--- keyBoard/Class/Pay/VC/KBJfPay.m | 7 ++-- keyBoard/Class/Pay/VC/KBVipPay.m | 2 +- 9 files changed, 92 insertions(+), 17 deletions(-) diff --git a/Shared/Localization/en.lproj/Localizable.strings b/Shared/Localization/en.lproj/Localizable.strings index 1c548f1..bb37890 100644 --- a/Shared/Localization/en.lproj/Localizable.strings +++ b/Shared/Localization/en.lproj/Localizable.strings @@ -32,6 +32,10 @@ "Failed to save login state" = "Failed to save login state"; "请切换到主App完成登录" = "Please switch to the main app to finish signing in"; +// Language switching prompt +"Change Language" = "Change Language"; +"Changing language will reload the Home screen." = "Changing language will reload the Home screen."; + // Generic buttons & tips "OK" = "OK"; "Confirm" = "Confirm"; @@ -82,6 +86,19 @@ "Mine" = "Mine"; "Hot" = "Hot"; "Rank" = "Rank"; +"Recharge Now" = "Recharge Now"; +"By clicking Pay, you indicate your agreement to the" = "By clicking Pay, you indicate your agreement to the"; +"《Embership Agreement》" = "《Embership Agreement》"; + +// Mine +"Settings" = "Settings"; +"My Keyboard" = "My Keyboard"; +"Notice" = "Notice"; +"Share App" = "Share App"; +"Feedback" = "Feedback"; +"E-mail" = "E-mail"; +"Agreement" = "Agreement"; +"Privacy Policy" = "Privacy Policy"; // Search & history "Clear history" = "Clear history"; diff --git a/Shared/Localization/zh-Hans.lproj/Localizable.strings b/Shared/Localization/zh-Hans.lproj/Localizable.strings index aadac04..52b5549 100644 --- a/Shared/Localization/zh-Hans.lproj/Localizable.strings +++ b/Shared/Localization/zh-Hans.lproj/Localizable.strings @@ -32,6 +32,10 @@ "Failed to save login state" = "保存登录态失败"; "请切换到主App完成登录" = "请切换到主App完成登录"; +// 语言切换提示 +"Change Language" = "切换语言"; +"Changing language will reload the Home screen." = "切换语言后将重新加载首页。"; + // 通用按钮与提示(英文 key) "OK" = "好"; "Confirm" = "确定"; @@ -83,6 +87,19 @@ "Mine" = "我的"; "Hot" = "热门"; "Rank" = "排行"; +"Recharge Now" = "立即充值"; +"By clicking Pay, you indicate your agreement to the" = "点击“支付”即表示您同意"; +"《Embership Agreement》" = "会员协议"; + +// Mine +"Settings" = "设置"; +"My Keyboard" = "我的键盘"; +"Notice" = "通知"; +"Share App" = "分享app"; +"Feedback" = "反馈"; +"E-mail" = "邮箱"; +"Agreement" = "协议"; +"Privacy Policy" = "隐私政策"; // 搜索与历史(英文 key) "Clear history" = "清空历史"; @@ -190,3 +207,8 @@ "螃蟹啊斯柯达积分卡" = "螃蟹啊斯柯达积分卡"; "❎不是自己的键盘" = "❎不是自己的键盘"; "是自己的键盘" = "是自己的键盘"; + + +"Change The Nickname" = "修改名称"; +"Please Enter The Modified Nickname" = "请输入修改后的昵称"; +"Save" = "保存"; diff --git a/keyBoard/Class/Home/V/HomeHeadView.m b/keyBoard/Class/Home/V/HomeHeadView.m index 0d40fee..f7b1a86 100644 --- a/keyBoard/Class/Home/V/HomeHeadView.m +++ b/keyBoard/Class/Home/V/HomeHeadView.m @@ -234,7 +234,7 @@ - (UIButton *)buyButton { if (!_buyButton) { _buyButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_buyButton setTitle:@"Recharge Now" forState:UIControlStateNormal]; + [_buyButton setTitle:KBLocalized(@"Recharge Now") forState:UIControlStateNormal]; [_buyButton setTitleColor:[UIColor colorWithHex:0x1B1F1A] forState:UIControlStateNormal]; _buyButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium]; [_buyButton setBackgroundImage:[UIImage imageNamed:@"recharge_now_icon"] forState:UIControlStateNormal]; diff --git a/keyBoard/Class/Home/VC/FunctionTest/KBLangTestVC.m b/keyBoard/Class/Home/VC/FunctionTest/KBLangTestVC.m index cdf33b0..ab2708f 100644 --- a/keyBoard/Class/Home/VC/FunctionTest/KBLangTestVC.m +++ b/keyBoard/Class/Home/VC/FunctionTest/KBLangTestVC.m @@ -52,9 +52,44 @@ } - (void)onToggle { - KBLocalizationManager *mgr = [KBLocalizationManager shared]; - NSString *next = [mgr.currentLanguageCode.lowercaseString hasPrefix:@"zh"] ? @"en" : @"zh-Hans"; - [mgr setCurrentLanguageCode:next persist:YES]; + // 弹出系统提示,确认后再切换语言并重建根控制器 + NSString *title = KBLocalized(@"Change Language"); + NSString *msg = KBLocalized(@"Changing language will reload the Home screen."); + + UIAlertController *ac = [UIAlertController alertControllerWithTitle:title + message:msg + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *cancel = [UIAlertAction actionWithTitle:KBLocalized(@"Cancel") + style:UIAlertActionStyleCancel + handler:nil]; + __weak typeof(self) weakSelf = self; + UIAlertAction *ok = [UIAlertAction actionWithTitle:KBLocalized(@"Confirm") + style:UIAlertActionStyleDefault + handler:^(__unused UIAlertAction * _Nonnull action) { + __strong typeof(weakSelf) self = weakSelf; + if (!self) return; + + KBLocalizationManager *mgr = [KBLocalizationManager shared]; + NSString *next = [mgr.currentLanguageCode.lowercaseString hasPrefix:@"zh"] ? @"en" : @"zh-Hans"; + [mgr setCurrentLanguageCode:next persist:YES]; + + // 语言切换后重新进入根控制器 + dispatch_async(dispatch_get_main_queue(), ^{ + id appDelegate = UIApplication.sharedApplication.delegate; + if ([appDelegate respondsToSelector:@selector(setupRootVC)]) { + // 使用 AppDelegate 的统一入口 + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [appDelegate performSelector:@selector(setupRootVC)]; + #pragma clang diagnostic pop + } + }); + }]; + + [ac addAction:cancel]; + [ac addAction:ok]; + [self presentViewController:ac animated:YES completion:nil]; } @end diff --git a/keyBoard/Class/Me/V/KBMyHeaderView.m b/keyBoard/Class/Me/V/KBMyHeaderView.m index c7ec8b4..ba28307 100644 --- a/keyBoard/Class/Me/V/KBMyHeaderView.m +++ b/keyBoard/Class/Me/V/KBMyHeaderView.m @@ -107,7 +107,7 @@ - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; - _titleLabel.text = @"Settings"; // 大标题 + _titleLabel.text = KBLocalized(@"Settings"); // 大标题 _titleLabel.font = [UIFont systemFontOfSize:30 weight:UIFontWeightBold]; _titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A]; } @@ -117,7 +117,7 @@ - (UIButton *)keyboardBtn { if (!_keyboardBtn) { _keyboardBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - [_keyboardBtn setTitle:@"My Keyboard" forState:UIControlStateNormal]; + [_keyboardBtn setTitle:KBLocalized(@"My Keyboard") forState:UIControlStateNormal]; _keyboardBtn.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightSemibold]; [_keyboardBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _keyboardBtn.backgroundColor = [UIColor colorWithHex:KBColorValue]; diff --git a/keyBoard/Class/Me/VC/KBMyKeyBoardVC.m b/keyBoard/Class/Me/VC/KBMyKeyBoardVC.m index a28979e..b68ea64 100644 --- a/keyBoard/Class/Me/VC/KBMyKeyBoardVC.m +++ b/keyBoard/Class/Me/VC/KBMyKeyBoardVC.m @@ -260,7 +260,7 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId"; - (UIButton *)saveButton { if (!_saveButton) { _saveButton = [UIButton buttonWithType:UIButtonTypeSystem]; - [_saveButton setTitle:@"Save" forState:UIControlStateNormal]; + [_saveButton setTitle:KBLocalized(@"Save") forState:UIControlStateNormal]; _saveButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold]; [_saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _saveButton.backgroundColor = [UIColor colorWithHex:KBColorValue]; diff --git a/keyBoard/Class/Me/VC/MyVC.m b/keyBoard/Class/Me/VC/MyVC.m index e696a02..e712c8f 100644 --- a/keyBoard/Class/Me/VC/MyVC.m +++ b/keyBoard/Class/Me/VC/MyVC.m @@ -35,12 +35,12 @@ // 数据源(title + SF Symbols 名称 + 色值),分两组 self.data = @[ - @[@{ @"title": @"Notice", @"icon": @"my_notice_icon", @"color": @(0x60A3FF) }], - @[@{ @"title": @"Share App", @"icon": @"my_share_icon", @"color": @(0xF5A623) }], - @[@{ @"title": @"Feedback", @"icon": @"my_feedback_icon", @"color": @(0xB06AFD) }, - @{ @"title": @"E-mail", @"icon": @"my_email_icon", @"color": @(0xFF8A65) }, - @{ @"title": @"Agreement", @"icon": @"my_agreement_icon", @"color": @(0x4CD964) }, - @{ @"title": @"Privacy Policy", @"icon": @"my_privacy_icon", @"color": @(0x5AC8FA) }] + @[@{ @"title": KBLocalized(@"Notice"), @"icon": @"my_notice_icon", @"color": @(0x60A3FF) }], + @[@{ @"title": KBLocalized(@"Share App"), @"icon": @"my_share_icon", @"color": @(0xF5A623) }], + @[@{ @"title": KBLocalized(@"Feedback"), @"icon": @"my_feedback_icon", @"color": @(0xB06AFD) }, + @{ @"title": KBLocalized(@"E-mail"), @"icon": @"my_email_icon", @"color": @(0xFF8A65) }, + @{ @"title": KBLocalized(@"Agreement"), @"icon": @"my_agreement_icon", @"color": @(0x4CD964) }, + @{ @"title": KBLocalized(@"Privacy Policy"), @"icon": @"my_privacy_icon", @"color": @(0x5AC8FA) }] ]; [self.view addSubview:self.tableView]; diff --git a/keyBoard/Class/Pay/VC/KBJfPay.m b/keyBoard/Class/Pay/VC/KBJfPay.m index 5a525f6..e2edf54 100644 --- a/keyBoard/Class/Pay/VC/KBJfPay.m +++ b/keyBoard/Class/Pay/VC/KBJfPay.m @@ -331,7 +331,7 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; - (UIButton *)payButton { if (!_payButton) { _payButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_payButton setTitle:@"Recharge Now" forState:UIControlStateNormal]; + [_payButton setTitle:KBLocalized(@"Recharge Now") forState:UIControlStateNormal]; [_payButton setTitleColor:[UIColor colorWithHex:KBBlackValue] forState:UIControlStateNormal]; _payButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; // 使用现有的切图(若不存在可退化为渐变图片) @@ -350,7 +350,8 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; - (UILabel *)agreementLabel { if (!_agreementLabel) { _agreementLabel = [UILabel new]; - _agreementLabel.text = @"By clicking Pay, you indicate your agreement to the"; // 简化文案 + + _agreementLabel.text = KBLocalized(@"By clicking Pay, you indicate your agreement to the"); // 简化文案 _agreementLabel.font = [UIFont systemFontOfSize:11 weight:UIFontWeightRegular]; _agreementLabel.textColor = [UIColor colorWithWhite:0.45 alpha:1.0]; } @@ -359,7 +360,7 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId"; - (UIButton *)agreementButton { if (!_agreementButton) { _agreementButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_agreementButton setTitle:@"《Embership Agreement》" forState:UIControlStateNormal]; + [_agreementButton setTitle:KBLocalized(@"《Embership Agreement》") forState:UIControlStateNormal]; [_agreementButton setTitleColor:[UIColor colorWithHex:KBColorValue] forState:UIControlStateNormal]; _agreementButton.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightSemibold]; diff --git a/keyBoard/Class/Pay/VC/KBVipPay.m b/keyBoard/Class/Pay/VC/KBVipPay.m index e75f55f..c889bda 100644 --- a/keyBoard/Class/Pay/VC/KBVipPay.m +++ b/keyBoard/Class/Pay/VC/KBVipPay.m @@ -265,7 +265,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId"; - (UIButton *)payButton { if (!_payButton) { _payButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_payButton setTitle:@"Recharge Now" forState:UIControlStateNormal]; + [_payButton setTitle:KBLocalized(@"Recharge Now") forState:UIControlStateNormal]; [_payButton setTitleColor:[UIColor colorWithHex:KBBlackValue] forState:UIControlStateNormal]; _payButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; UIImage *bg = [UIImage imageNamed:@"recharge_now_icon"];