key缺少,添加权限多语言

This commit is contained in:
2026-03-07 13:29:29 +08:00
parent e03287605c
commit cbcf8c4197
47 changed files with 986 additions and 225 deletions

View File

@@ -106,7 +106,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
}
}
if (trim.length == 0) {
[KBHUD showInfo:KBLocalized(@"请输入内容")];
[KBHUD showInfo:KBLocalized(@"Please enter content")];
return;
}
[self kb_sendChatText:trim];
@@ -128,7 +128,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
[self kb_prefetchAvatarForMessage:outgoing];
if (![[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self.view]) {
[KBHUD showInfo:KBLocalized(@"请开启完全访问后使用")];
[KBHUD showInfo:KBLocalized(@"Please enable Full Access to continue")];
return;
}
@@ -259,12 +259,12 @@ static const NSUInteger kKBChatMessageLimit = 6;
if (mockPath.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
NSString *displayText = KBLocalized(@"语音回复");
NSString *displayText = KBLocalized(@"Voice reply");
KBChatMessage *incoming =
[KBChatMessage messageWithText:displayText
outgoing:NO
audioFilePath:mockPath];
incoming.displayName = KBLocalized(@"AI助手");
incoming.displayName = KBLocalized(@"AI Assistant");
[self kb_appendChatMessage:incoming];
[self kb_playChatAudioAtPath:mockPath];
});
@@ -284,7 +284,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
}
if (error) {
NSString *tip = error.localizedDescription
?: KBLocalized(@"请求失败");
?: KBLocalized(@"Request failed");
[KBHUD showInfo:tip];
return;
}
@@ -304,7 +304,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
initWithBase64EncodedString:audioBase64
options:0];
if (data.length == 0) {
[KBHUD showInfo:KBLocalized(@"音频数据解析失败")];
[KBHUD showInfo:KBLocalized(@"Failed to parse audio data")];
return;
}
[self kb_handleChatAudioData:data
@@ -312,7 +312,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
displayText:displayText];
return;
}
[KBHUD showInfo:KBLocalized(@"未获取到音频文件")];
[KBHUD showInfo:KBLocalized(@"No audio file received")];
});
}];
}
@@ -352,7 +352,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
[self.chatPanelView
kb_removeLoadingAssistantMessage];
[KBHUD showInfo:response.message
?: KBLocalized(@"请求失败")];
?: KBLocalized(@"Request failed")];
return;
}
@@ -362,7 +362,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
if (response.data.aiResponse.length == 0) {
[self.chatPanelView
kb_removeLoadingAssistantMessage];
[KBHUD showInfo:KBLocalized(@"未获取到回复内容")];
[KBHUD showInfo:KBLocalized(@"No reply content received")];
return;
}
@@ -450,13 +450,13 @@ static const NSUInteger kKBChatMessageLimit = 6;
if (!response.success) {
[KBHUD showInfo:response.errorMessage
?: KBLocalized(@"下载失败")];
?: KBLocalized(@"Download failed")];
return;
}
if (!response.audioData ||
response.audioData.length == 0) {
[KBHUD showInfo:KBLocalized(@"未获取到音频数据")];
[KBHUD showInfo:KBLocalized(@"No audio data received")];
return;
}
@@ -475,7 +475,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
fileExtension:(NSString *)extension
displayText:(NSString *)displayText {
if (data.length == 0) {
[KBHUD showInfo:KBLocalized(@"音频数据为空")];
[KBHUD showInfo:KBLocalized(@"Audio data is empty")];
return;
}
NSString *ext = extension.length > 0 ? extension : @"m4a";
@@ -487,14 +487,14 @@ static const NSUInteger kKBChatMessageLimit = 6;
NSString *filePath =
[NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
if (![data writeToFile:filePath atomically:YES]) {
[KBHUD showInfo:KBLocalized(@"音频保存失败")];
[KBHUD showInfo:KBLocalized(@"Failed to save audio")];
return;
}
NSString *text =
displayText.length > 0 ? displayText : KBLocalized(@"语音消息");
displayText.length > 0 ? displayText : KBLocalized(@"Voice message");
KBChatMessage *incoming =
[KBChatMessage messageWithText:text outgoing:NO audioFilePath:filePath];
incoming.displayName = KBLocalized(@"AI助手");
incoming.displayName = KBLocalized(@"AI Assistant");
[self kb_appendChatMessage:incoming];
}
@@ -594,7 +594,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
}
NSURL *url = [NSURL fileURLWithPath:path];
if (![NSFileManager.defaultManager fileExistsAtPath:path]) {
[KBHUD showInfo:KBLocalized(@"音频文件不存在")];
[KBHUD showInfo:KBLocalized(@"Audio file does not exist")];
return;
}
@@ -624,7 +624,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
AVAudioPlayer *player =
[[AVAudioPlayer alloc] initWithContentsOfURL:url error:&playerError];
if (playerError || !player) {
[KBHUD showInfo:KBLocalized(@"音频播放失败")];
[KBHUD showInfo:KBLocalized(@"Audio playback failed")];
return;
}
self.chatAudioPlayer = player;
@@ -664,7 +664,7 @@ static const NSUInteger kKBChatMessageLimit = 6;
if (playerError || !player) {
NSLog(@"[Keyboard] 音频播放器初始化失败: %@",
playerError.localizedDescription);
[KBHUD showInfo:KBLocalized(@"音频播放失败")];
[KBHUD showInfo:KBLocalized(@"Audio playback failed")];
return;
}

View File

@@ -758,7 +758,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
// 1) 访
if (![[KBFullAccessManager shared] hasFullAccess]) {
// 访
// [KBHUD showInfo:KBLocalized(@"处理中…")];
// [KBHUD showInfo:KBLocalized(@"Processing...")];
[[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self.view];
return;
}
@@ -1109,7 +1109,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
[rawText stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (trim.length == 0) {
[KBHUD showInfo:KBLocalized(@"请输入内容")];
[KBHUD showInfo:KBLocalized(@"Please enter content")];
return;
}
[self kb_sendChatText:trim];
@@ -1129,7 +1129,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
[self kb_prefetchAvatarForMessage:outgoing];
if (![[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self.view]) {
[KBHUD showInfo:KBLocalized(@"请开启完全访问后使用")];
[KBHUD showInfo:KBLocalized(@"Please enable Full Access to continue")];
return;
}
@@ -1258,12 +1258,12 @@ static NSString *KBFormatMB(uint64_t bytes) {
if (mockPath.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
NSString *displayText = KBLocalized(@"语音回复");
NSString *displayText = KBLocalized(@"Voice reply");
KBChatMessage *incoming =
[KBChatMessage messageWithText:displayText
outgoing:NO
audioFilePath:mockPath];
incoming.displayName = KBLocalized(@"AI助手");
incoming.displayName = KBLocalized(@"AI Assistant");
[self kb_appendChatMessage:incoming];
[self kb_playChatAudioAtPath:mockPath];
});
@@ -1283,7 +1283,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
}
if (error) {
NSString *tip = error.localizedDescription
?: KBLocalized(@"请求失败");
?: KBLocalized(@"Request failed");
[KBHUD showInfo:tip];
return;
}
@@ -1303,7 +1303,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
initWithBase64EncodedString:audioBase64
options:0];
if (data.length == 0) {
[KBHUD showInfo:KBLocalized(@"音频数据解析失败")];
[KBHUD showInfo:KBLocalized(@"Failed to parse audio data")];
return;
}
[self kb_handleChatAudioData:data
@@ -1311,7 +1311,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
displayText:displayText];
return;
}
[KBHUD showInfo:KBLocalized(@"未获取到音频文件")];
[KBHUD showInfo:KBLocalized(@"No audio file received")];
});
}];
}
@@ -1344,7 +1344,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
}
NSLog(@"[KB] ❌ 请求失败: %@", response.message);
[self.chatPanelView kb_removeLoadingAssistantMessage];
[KBHUD showInfo:response.message ?: KBLocalized(@"请求失败")];
[KBHUD showInfo:response.message ?: KBLocalized(@"Request failed")];
return;
}
@@ -1352,7 +1352,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
if (response.data.aiResponse.length == 0) {
[self.chatPanelView kb_removeLoadingAssistantMessage];
[KBHUD showInfo:KBLocalized(@"未获取到回复内容")];
[KBHUD showInfo:KBLocalized(@"No reply content received")];
return;
}
@@ -1420,12 +1420,12 @@ static NSString *KBFormatMB(uint64_t bytes) {
if (!self) return;
if (!response.success) {
[KBHUD showInfo:response.errorMessage ?: KBLocalized(@"下载失败")];
[KBHUD showInfo:response.errorMessage ?: KBLocalized(@"Download failed")];
return;
}
if (!response.audioData || response.audioData.length == 0) {
[KBHUD showInfo:KBLocalized(@"未获取到音频数据")];
[KBHUD showInfo:KBLocalized(@"No audio data received")];
return;
}
@@ -1444,7 +1444,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
fileExtension:(NSString *)extension
displayText:(NSString *)displayText {
if (data.length == 0) {
[KBHUD showInfo:KBLocalized(@"音频数据为空")];
[KBHUD showInfo:KBLocalized(@"Audio data is empty")];
return;
}
NSString *ext = extension.length > 0 ? extension : @"m4a";
@@ -1456,15 +1456,15 @@ static NSString *KBFormatMB(uint64_t bytes) {
NSString *filePath =
[NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
if (![data writeToFile:filePath atomically:YES]) {
[KBHUD showInfo:KBLocalized(@"音频保存失败")];
[KBHUD showInfo:KBLocalized(@"Failed to save audio")];
return;
}
NSString *text = displayText.length > 0 ? displayText : KBLocalized(@"语音消息");
NSString *text = displayText.length > 0 ? displayText : KBLocalized(@"Voice message");
KBChatMessage *incoming =
[KBChatMessage messageWithText:text
outgoing:NO
audioFilePath:filePath];
incoming.displayName = KBLocalized(@"AI助手");
incoming.displayName = KBLocalized(@"AI Assistant");
[self kb_appendChatMessage:incoming];
}
@@ -1566,7 +1566,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
}
NSURL *url = [NSURL fileURLWithPath:path];
if (![NSFileManager.defaultManager fileExistsAtPath:path]) {
[KBHUD showInfo:KBLocalized(@"音频文件不存在")];
[KBHUD showInfo:KBLocalized(@"Audio file does not exist")];
return;
}
@@ -1596,7 +1596,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
AVAudioPlayer *player =
[[AVAudioPlayer alloc] initWithContentsOfURL:url error:&playerError];
if (playerError || !player) {
[KBHUD showInfo:KBLocalized(@"音频播放失败")];
[KBHUD showInfo:KBLocalized(@"Audio playback failed")];
return;
}
self.chatAudioPlayer = player;
@@ -1634,7 +1634,7 @@ static NSString *KBFormatMB(uint64_t bytes) {
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:audioData error:&playerError];
if (playerError || !player) {
NSLog(@"[Keyboard] 音频播放器初始化失败: %@", playerError.localizedDescription);
[KBHUD showInfo:KBLocalized(@"音频播放失败")];
[KBHUD showInfo:KBLocalized(@"Audio playback failed")];
return;
}

View File

@@ -54,7 +54,7 @@
}
#endif
if (mode == KBKeyboardPanelModeFunction && !islogin) {
[KBHUD showInfo:KBLocalized(@"请先登录后使用AI功能")];
[KBHUD showInfo:KBLocalized(@"Please sign in before using AI features")];
NSURL *ul = [NSURL URLWithString:[NSString stringWithFormat:@"%@?src=keyboard", KB_UL_LOGIN]];
NSURL *scheme =
[NSURL URLWithString:[NSString stringWithFormat:@"%@://login?src=keyboard", KB_APP_SCHEME]];
@@ -68,7 +68,7 @@
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
[KBHUD showInfo:KBLocalized(@"请回到桌面手动打开App登录")];
[KBHUD showInfo:KBLocalized(@"Please return to the Home screen and open the app to sign in")];
});
}];
return;

View File

@@ -19,7 +19,7 @@
// 1) 访
if (![[KBFullAccessManager shared] hasFullAccess]) {
// 访
// [KBHUD showInfo:KBLocalized(@"处理中…")];
// [KBHUD showInfo:KBLocalized(@"Processing...")];
[[KBFullAccessManager shared] ensureFullAccessOrGuideInView:self.view];
return;
}