key缺少,添加权限多语言
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user