mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 08:06:46 +01:00
- added short date format definition in language.json - changed english date format to mm/dd - added lightgrey (4)/darkgrey (5)/pink (6) colors in jsontemplate (uses pattern dither) - fixed ntp init timing
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 > 8) {
|
|
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;
|
|
}
|
|
|
|
DynamicJsonDocument doc(1024);
|
|
StaticJsonDocument<80> 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>();
|
|
}
|
|
}
|
|
|