forked from xiaozhi/xiaozhi-esp32
添加多国语言支持
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "application.h"
|
||||
#include "board.h"
|
||||
#include "display.h"
|
||||
#include "ssd1306_display.h"
|
||||
#include "system_info.h"
|
||||
#include "ml307_ssl_transport.h"
|
||||
#include "audio_codec.h"
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "font_awesome_symbols.h"
|
||||
#include "iot/thing_manager.h"
|
||||
#include "assets/zh/binary.h"
|
||||
#include "assets/lang_config.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <esp_log.h>
|
||||
@@ -117,7 +119,7 @@ void Application::CheckNewVersion() {
|
||||
|
||||
// No new version, mark the current version as valid
|
||||
ota_.MarkCurrentVersionValid();
|
||||
display->ShowNotification("版本 " + ota_.GetCurrentVersion());
|
||||
display->ShowNotification(Lang::Strings::VERSION + " " + ota_.GetCurrentVersion());
|
||||
|
||||
if (ota_.HasActivationCode()) {
|
||||
// Activation code is valid
|
||||
@@ -218,7 +220,7 @@ void Application::ToggleChatState() {
|
||||
if (device_state_ == kDeviceStateIdle) {
|
||||
SetDeviceState(kDeviceStateConnecting);
|
||||
if (!protocol_->OpenAudioChannel()) {
|
||||
Alert("ERROR", "无法建立音频通道", "sad");
|
||||
Alert("ERROR", Lang::Strings::UNABLE_TO_ESTABLISH_AUDIO_CHANNEL, "sad");
|
||||
SetDeviceState(kDeviceStateIdle);
|
||||
return;
|
||||
}
|
||||
@@ -252,7 +254,7 @@ void Application::StartListening() {
|
||||
SetDeviceState(kDeviceStateConnecting);
|
||||
if (!protocol_->OpenAudioChannel()) {
|
||||
SetDeviceState(kDeviceStateIdle);
|
||||
Alert("ERROR", "无法建立音频通道", "sad");
|
||||
Alert("ERROR", Lang::Strings::UNABLE_TO_ESTABLISH_AUDIO_CHANNEL, "sad");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -326,7 +328,7 @@ void Application::Start() {
|
||||
board.StartNetwork();
|
||||
|
||||
// Initialize the protocol
|
||||
display->SetStatus("加载协议...");
|
||||
display->SetStatus(Lang::Strings::LOADING_PROTOCOL + "...");
|
||||
#ifdef CONFIG_CONNECTION_TYPE_WEBSOCKET
|
||||
protocol_ = std::make_unique<WebsocketProtocol>();
|
||||
#else
|
||||
@@ -662,18 +664,18 @@ void Application::SetDeviceState(DeviceState state) {
|
||||
switch (state) {
|
||||
case kDeviceStateUnknown:
|
||||
case kDeviceStateIdle:
|
||||
display->SetStatus("待命");
|
||||
display->SetStatus(Lang::Strings::STANDING_BY);
|
||||
display->SetEmotion("neutral");
|
||||
#ifdef CONFIG_USE_AUDIO_PROCESSING
|
||||
audio_processor_.Stop();
|
||||
#endif
|
||||
break;
|
||||
case kDeviceStateConnecting:
|
||||
display->SetStatus("连接中...");
|
||||
display->SetStatus(Lang::Strings::CONNECTING+"...");
|
||||
display->SetChatMessage("system", "");
|
||||
break;
|
||||
case kDeviceStateListening:
|
||||
display->SetStatus("聆听中...");
|
||||
display->SetStatus(Lang::Strings::LISTENING+"...");
|
||||
display->SetEmotion("neutral");
|
||||
ResetDecoder();
|
||||
opus_encoder_->ResetState();
|
||||
@@ -683,7 +685,7 @@ void Application::SetDeviceState(DeviceState state) {
|
||||
UpdateIotStates();
|
||||
break;
|
||||
case kDeviceStateSpeaking:
|
||||
display->SetStatus("说话中...");
|
||||
display->SetStatus(Lang::Strings::SPEAKING+"...");
|
||||
ResetDecoder();
|
||||
codec->EnableOutput(true);
|
||||
#if CONFIG_USE_AUDIO_PROCESSING
|
||||
|
||||
Reference in New Issue
Block a user