forked from xiaozhi/xiaozhi-esp32
添加多国语言支持
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <ml307_udp.h>
|
||||
#include <cstring>
|
||||
#include <arpa/inet.h>
|
||||
#include "assets/lang_config.h"
|
||||
|
||||
#define TAG "MQTT"
|
||||
|
||||
@@ -87,7 +88,7 @@ bool MqttProtocol::StartMqttClient() {
|
||||
if (!mqtt_->Connect(endpoint_, 8883, client_id_, username_, password_)) {
|
||||
ESP_LOGE(TAG, "Failed to connect to endpoint");
|
||||
if (on_network_error_ != nullptr) {
|
||||
on_network_error_("无法连接服务");
|
||||
on_network_error_(Lang::Strings::UNABLE_TO_CONNECT_TO_SERVICE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -103,7 +104,7 @@ void MqttProtocol::SendText(const std::string& text) {
|
||||
if (!mqtt_->Publish(publish_topic_, text)) {
|
||||
ESP_LOGE(TAG, "Failed to publish message");
|
||||
if (on_network_error_ != nullptr) {
|
||||
on_network_error_("发送失败,请检查网络");
|
||||
on_network_error_(Lang::Strings::SENDING_FAILED_PLEASE_CHECK_THE_NETWORK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +179,7 @@ bool MqttProtocol::OpenAudioChannel() {
|
||||
if (!(bits & MQTT_PROTOCOL_SERVER_HELLO_EVENT)) {
|
||||
ESP_LOGE(TAG, "Failed to receive server hello");
|
||||
if (on_network_error_ != nullptr) {
|
||||
on_network_error_("等待响应超时");
|
||||
on_network_error_(Lang::Strings::WAITING_FOR_RESPONSE_TIMEOUT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <cJSON.h>
|
||||
#include <esp_log.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "assets/lang_config.h"
|
||||
|
||||
#define TAG "WS"
|
||||
|
||||
@@ -98,7 +99,7 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
||||
if (!websocket_->Connect(url.c_str())) {
|
||||
ESP_LOGE(TAG, "Failed to connect to websocket server");
|
||||
if (on_network_error_ != nullptr) {
|
||||
on_network_error_("无法连接服务");
|
||||
on_network_error_(Lang::Strings::UNABLE_TO_CONNECT_TO_SERVICE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -119,7 +120,7 @@ bool WebsocketProtocol::OpenAudioChannel() {
|
||||
if (!(bits & WEBSOCKET_PROTOCOL_SERVER_HELLO_EVENT)) {
|
||||
ESP_LOGE(TAG, "Failed to receive server hello");
|
||||
if (on_network_error_ != nullptr) {
|
||||
on_network_error_("等待响应超时");
|
||||
on_network_error_(Lang::Strings::WAITING_FOR_RESPONSE_TIMEOUT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user