添加多国语言支持

This commit is contained in:
VinJay
2025-02-18 19:33:07 +08:00
parent 140aab8999
commit d5594d01a3
12 changed files with 206 additions and 27 deletions

View File

@@ -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;
}