-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_translate.ino
More file actions
55 lines (43 loc) · 1.32 KB
/
Copy pathbasic_translate.ino
File metadata and controls
55 lines (43 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <Arduino.h>
#include <ESPLang.h>
namespace AppLanguage {
static constexpr LangLanguageId EN = 1;
static constexpr LangLanguageId HU = 2;
} // namespace AppLanguage
enum class AppText : uint16_t {
TestMessage = 1,
WifiConnected = 2,
};
static const LangTranslationEntry kEnglish[] = {
ESP_LANG_ENTRY(AppText::TestMessage, "Test message"),
ESP_LANG_ENTRY(AppText::WifiConnected, "Connected to WiFi"),
};
static const LangTranslationEntry kHungarian[] = {
ESP_LANG_ENTRY(AppText::TestMessage, "Teszt uzenet"),
ESP_LANG_ENTRY(AppText::WifiConnected, "WiFi csatlakoztatva"),
};
static const LangTranslationTable kTables[] = {
makeLangTable(AppLanguage::EN, kEnglish),
makeLangTable(AppLanguage::HU, kHungarian),
};
ESPLang lang;
void setup() {
Serial.begin(115200);
ESPLangConfig config{};
config.tables = kTables;
config.tableCount = sizeof(kTables) / sizeof(kTables[0]);
config.defaultLanguage = AppLanguage::EN;
config.useDefaultFallback = true;
config.missingText = "[missing]";
if (!lang.init(config)) {
Serial.println("ESPLang init failed");
return;
}
Serial.println(lang.translate(AppText::TestMessage));
lang.setLanguage(AppLanguage::HU);
Serial.println(lang.translate(AppText::TestMessage));
Serial.println(lang.translate(AppText::WifiConnected));
}
void loop() {
delay(1000);
}