mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 12:05:51 +01:00
* updated arduinojson to version 7.3.0, enabled comments within json files * update ESPAsyncWebServer/AsyncTCP to the ESP32Async fork ESP32Async/ESPAsyncWebServer and ESP32Async/AsyncTCP are much better maintained and it looks like a lot of bugs are fixed compared to the ESPHome version we used before. * Arduino 3.x compatibility (while maintaining 2.x compatibility)
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
#include "language.h"
|
|
|
|
#include <Arduino.h>
|
|
#include <ArduinoJson.h>
|
|
#include <FS.h>
|
|
|
|
#include "settings.h"
|
|
#include "storage.h"
|
|
#include "tag_db.h"
|
|
|
|
String languageDaysShort[7];
|
|
String languageDays[7];
|
|
String languageMonth[12];
|
|
String languageDateFormat[5];
|
|
|
|
int currentLanguage = 0;
|
|
|
|
void updateLanguageFromConfig() {
|
|
int tempLang = config.language;
|
|
if (tempLang < 0 || tempLang > 11) {
|
|
Serial.println("Language not supported");
|
|
return;
|
|
}
|
|
currentLanguage = tempLang;
|
|
|
|
File file = contentFS->open("/languages.json", "r");
|
|
if (!file) {
|
|
Serial.println("Failed to open languages.json file");
|
|
return;
|
|
}
|
|
|
|
JsonDocument doc;
|
|
JsonDocument filter;
|
|
filter[String(currentLanguage)] = true;
|
|
const DeserializationError error = deserializeJson(doc, file, DeserializationOption::Filter(filter));
|
|
file.close();
|
|
if (error) {
|
|
Serial.print("Failed to parse JSON: ");
|
|
Serial.println(error.c_str());
|
|
return;
|
|
}
|
|
JsonObject languageObject = doc[String(currentLanguage)];
|
|
for (int i = 0; i < 7; ++i) {
|
|
languageDaysShort[i] = languageObject["daysShort"][i].as<String>();
|
|
languageDays[i] = languageObject["days"][i].as<String>();
|
|
}
|
|
for (int i = 0; i < 12; ++i) {
|
|
languageMonth[i] = languageObject["months"][i].as<String>();
|
|
}
|
|
for (int i = 0; i < languageObject["date_format"].size(); i++) {
|
|
languageDateFormat[i] = languageObject["date_format"][i].as<String>();
|
|
}
|
|
}
|
|
|