mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2026-01-05 20:33:38 +01:00
Add API endpoint to retrieve custom languages and complete language pack
This commit is contained in:
27
include/I18n.h
Normal file
27
include/I18n.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
#include <WString.h>
|
||||
#include <list>
|
||||
|
||||
struct LanguageInfo_t {
|
||||
String code;
|
||||
String name;
|
||||
String filename;
|
||||
};
|
||||
|
||||
class I18nClass {
|
||||
public:
|
||||
I18nClass();
|
||||
void init(Scheduler& scheduler);
|
||||
std::list<LanguageInfo_t> getAvailableLanguages();
|
||||
|
||||
private:
|
||||
void readLangPacks();
|
||||
void readConfig(String file);
|
||||
|
||||
std::list<LanguageInfo_t> _availLanguages;
|
||||
};
|
||||
|
||||
extern I18nClass I18n;
|
||||
@@ -11,4 +11,5 @@ public:
|
||||
static int getTimezoneOffset();
|
||||
static bool checkJsonAlloc(const JsonDocument& doc, const char* function, const uint16_t line);
|
||||
static void removeAllFiles();
|
||||
static String generateMd5FromFile(String file);
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "WebApi_file.h"
|
||||
#include "WebApi_firmware.h"
|
||||
#include "WebApi_gridprofile.h"
|
||||
#include "WebApi_i18n.h"
|
||||
#include "WebApi_inverter.h"
|
||||
#include "WebApi_limit.h"
|
||||
#include "WebApi_maintenance.h"
|
||||
@@ -53,6 +54,7 @@ private:
|
||||
WebApiFileClass _webApiFile;
|
||||
WebApiFirmwareClass _webApiFirmware;
|
||||
WebApiGridProfileClass _webApiGridprofile;
|
||||
WebApiI18nClass _webApiI18n;
|
||||
WebApiInverterClass _webApiInverter;
|
||||
WebApiLimitClass _webApiLimit;
|
||||
WebApiMaintenanceClass _webApiMaintenance;
|
||||
|
||||
14
include/WebApi_i18n.h
Normal file
14
include/WebApi_i18n.h
Normal file
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
|
||||
class WebApiI18nClass {
|
||||
public:
|
||||
void init(AsyncWebServer& server, Scheduler& scheduler);
|
||||
|
||||
private:
|
||||
void onI18nLanguages(AsyncWebServerRequest* request);
|
||||
void onI18nLanguage(AsyncWebServerRequest* request);
|
||||
};
|
||||
@@ -108,3 +108,5 @@
|
||||
#define LED_BRIGHTNESS 100U
|
||||
|
||||
#define MAX_INVERTER_LIMIT 2250
|
||||
|
||||
#define LANG_PACK_SUFFIX ".lang.json"
|
||||
|
||||
Reference in New Issue
Block a user