Skip to content

Commit

Permalink
Added translations for portal text
Browse files Browse the repository at this point in the history
And removed FABLAB_* for FABOMATIC_*
CppLinter fixes
  • Loading branch information
PBrunot committed May 4, 2024
1 parent 18939fa commit 426fb45
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
8 changes: 7 additions & 1 deletion include/language/en-US.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@ namespace fabomatic::strings::en_US
static constexpr auto FACTORY_RESET_DONE_1 = "Factory reset";
static constexpr auto FACTORY_RESET_DONE_2 = "Wait reboot";

}
static constexpr auto PORTAL_TITLE = "FAB-O-MATIC";
static constexpr auto PORTAL_MACHINE_ID_PROMPT = "Machine ID";
static constexpr auto PORTAL_SHELLY_MQTT_PROMPT = "Shelly MQTT topic (can be empty)";
static constexpr auto PORTAL_MQTT_BROKER_PROMPT = "MQTT broker (IP or hostname)";

} // namespace fabomatic::strings::en_US

#endif
7 changes: 6 additions & 1 deletion include/language/it-IT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ namespace fabomatic::strings::it_IT
static constexpr auto FACTORY_RESET_DONE_1 = "Param. reset";
static constexpr auto FACTORY_RESET_DONE_2 = "Attesa reboot";

}
static constexpr auto PORTAL_TITLE = "FAB-O-MATIC";
static constexpr auto PORTAL_MACHINE_ID_PROMPT = "ID della macchina";
static constexpr auto PORTAL_SHELLY_MQTT_PROMPT = "Topic MQTT per Shelly (facoltativo)";
static constexpr auto PORTAL_MQTT_BROKER_PROMPT = "Indirizzo o nome MQTT broker";
} // namespace fabomatic::strings::it_IT

#endif
11 changes: 6 additions & 5 deletions include/language/lang.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _LANGUAGE_LANG_HPP
#define _LANGUAGE_LANG_HPP
#ifndef _FABOMATIC_LANG_HPP
#define _FABOMATIC_LANG_HPP

// Include Italian language
#if FABLAB_LANG_IT_IT
#if FABOMATIC_LANG_IT_IT
#include "language/it-IT.hpp"
namespace fabomatic::strings
{
Expand All @@ -11,7 +11,7 @@ namespace fabomatic::strings
#endif

// Include English language
#ifdef FABLAB_LANG_EN_US
#ifdef FABOMATIC_LANG_EN_US
#include "language/en-US.hpp"
namespace fabomatic::strings
{
Expand All @@ -20,4 +20,5 @@ namespace fabomatic::strings
#endif

// Repeat the pattern above if other languages are needed
#endif

#endif // _FABOMATIC_LANG_HPP
12 changes: 6 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ build_src_flags = ${env.build_src_flags}
-D RFID_SIMULATION=false
-D PINS_ESP32S3
-D DEBUG
-D FABLAB_LANG_IT_IT
-D FABOMATIC_LANG_IT_IT

[hardware-rev0-base]
board = esp32-s3-devkitc-1
Expand All @@ -91,12 +91,12 @@ build_src_flags = ${env.build_src_flags}
[env:hardware-rev0-it_IT]
extends = hardware-rev0-base
build_src_flags = ${hardware-rev0-base.build_src_flags}
-D FABLAB_LANG_IT_IT
-D FABOMATIC_LANG_IT_IT

[env:hardware-rev0-en_US]
extends = hardware-rev0-base
build_src_flags = ${hardware-rev0-base.build_src_flags}
-D FABLAB_LANG_EN_US
-D FABOMATIC_LANG_EN_US

[env:esp32-devboard]
board = esp32dev
Expand All @@ -106,7 +106,7 @@ build_src_flags = ${env.build_src_flags}
-D MQTT_SIMULATION=false
-D RFID_SIMULATION=false
-D PINS_ESP32
-D FABLAB_LANG_EN_US
-D FABOMATIC_LANG_EN_US

upload_protocol = espota
upload_port = board1
Expand All @@ -119,7 +119,7 @@ build_src_flags = ${env.build_src_flags}
-D MQTT_SIMULATION=true
-D RFID_SIMULATION=true
-D PINS_WOKWI
-D FABLAB_LANG_EN_US
-D FABOMATIC_LANG_EN_US

[env:wrover-kit-it_IT]
board = esp-wrover-kit
Expand All @@ -132,4 +132,4 @@ build_src_flags = ${env.build_src_flags}
-D RFID_SIMULATION=true
-D PINS_ESP32_WROVERKIT
-D DEBUG
-D FABLAB_LANG_IT_IT
-D FABOMATIC_LANG_IT_IT
9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "mock/MockMQTTBroker.hpp"
#endif
#include "pins.hpp"
#include "language/lang.hpp"

// For ArduinoOTA
const char *const ssid = fabomatic::secrets::credentials::ssid.data();
Expand Down Expand Up @@ -354,9 +355,9 @@ namespace fabomatic
config.mqtt_switch_topic.resize(conf::common::STR_MAX_LENGTH);
config.machine_id.resize(conf::common::INT_MAX_LENGTH);

WiFiManagerParameter custom_mqtt_server("Broker", "MQTT Broker address", config.mqtt_server.data(), conf::common::STR_MAX_LENGTH);
WiFiManagerParameter custom_mqtt_topic("Topic", "MQTT Switch topic (leave empty to disable)", config.mqtt_switch_topic.data(), conf::common::STR_MAX_LENGTH);
WiFiManagerParameter custom_machine_id("MachineID", "Machine ID", config.machine_id.data(), conf::common::INT_MAX_LENGTH, "type='number' min='0' max='65535'");
WiFiManagerParameter custom_mqtt_server("Broker", strings::PORTAL_MQTT_BROKER_PROMPT, config.mqtt_server.data(), conf::common::STR_MAX_LENGTH);
WiFiManagerParameter custom_mqtt_topic("Topic", strings::PORTAL_SHELLY_MQTT_PROMPT, config.mqtt_switch_topic.data(), conf::common::STR_MAX_LENGTH);
WiFiManagerParameter custom_machine_id("MachineID", strings::PORTAL_MACHINE_ID_PROMPT, config.machine_id.data(), conf::common::INT_MAX_LENGTH, "type='number' min='0' max='65535'");

wifiManager.addParameter(&custom_mqtt_server);
wifiManager.addParameter(&custom_mqtt_topic);
Expand All @@ -366,7 +367,7 @@ namespace fabomatic
wifiManager.setConnectRetries(3); // 3 retries
wifiManager.setConnectTimeout(10); // 10 seconds
wifiManager.setCountry("IT");
wifiManager.setTitle("FabLab Bergamo - RFID arduino");
wifiManager.setTitle(strings::PORTAL_TITLE);
wifiManager.setCaptivePortalEnable(true);
wifiManager.setAPCallback(configModeCallback);
wifiManager.setSaveConfigCallback(saveConfigCallback);
Expand Down
8 changes: 3 additions & 5 deletions src/mock/MockMQTTBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ namespace fabomatic
<< ",\"name\":\"User" << uid_str << "\"}";
return ss.str();
}
else
{
ESP_LOGE(TAG2, "Failed to parse checkuser query");
return "{\"request_ok\":false}";
}

ESP_LOGE(TAG2, "Failed to parse checkuser query");
return "{\"request_ok\":false}";
}

if (query.find("alive") != std::string::npos)
Expand Down

0 comments on commit 426fb45

Please sign in to comment.