Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pr display i18n new #1778

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/convertHtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ def main():
lang = "en"
if env['PIOENV'][-3:] == "-de":
lang = "de"
if env['PIOENV'][-3:] == "-fr":
lang = "fr"


# go throw the array
Expand Down
28 changes: 26 additions & 2 deletions src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ build_flags = ${env.build_flags}
monitor_filters =
esp8266_exception_decoder

[env:esp8266-fr]
platform = espressif8266
board = esp12e
board_build.f_cpu = 80000000L
build_flags = ${env.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DLANG_FR
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
;-Wl,-Map,output.map
monitor_filters =
esp8266_exception_decoder

[env:esp8266-prometheus]
platform = espressif8266
board = esp12e
Expand Down Expand Up @@ -104,8 +118,6 @@ build_flags = ${env.build_flags}
monitor_filters =
esp8266_exception_decoder



[env:esp8285]
platform = espressif8266
board = esp8285
Expand Down Expand Up @@ -164,6 +176,18 @@ build_flags = ${env.build_flags}
monitor_filters =
esp32_exception_decoder

[env:esp32-wroom32-fr]
platform = [email protected]
board = lolin_d32
build_flags = ${env.build_flags}
-DUSE_HSPI_FOR_EPD
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
-DLANG_FR
monitor_filters =
esp32_exception_decoder

[env:esp32-wroom32-prometheus]
platform = [email protected]
board = lolin_d32
Expand Down
1 change: 1 addition & 0 deletions src/plugins/Display/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../../hm/hmSystem.h"
#include "../../hm/hmRadio.h"
#include "../../utils/helper.h"
#include "../plugin_lang.h"
#include "Display_Mono.h"
#include "Display_Mono_128X32.h"
#include "Display_Mono_128X64.h"
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/Display/Display_Mono_128X64.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DisplayMono128X64 : public DisplayMono {

// print Date and time
if (0 != mDisplayData->utcTs)
printText(ah::getDateTimeStrShort(mDisplayData->utcTs).c_str(), l_Time, 0xff);
printText(ah::getDateTimeStrShort_i18n(mDisplayData->utcTs).c_str(), l_Time, 0xff);

if (showLine(l_Status)) {
// alternatively:
Expand All @@ -108,7 +108,7 @@ class DisplayMono128X64 : public DisplayMono {
int8_t moon_pos = -1;
setLineFont(l_Status);
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "no inverter");
snprintf(mFmtText, DISP_FMT_TEXT_LEN, STR_NO_INVERTER);
else if (0 == mDisplayData->nrSleeping) {
snprintf(mFmtText, DISP_FMT_TEXT_LEN, " ");
sun_pos = 0;
Expand Down Expand Up @@ -145,7 +145,7 @@ class DisplayMono128X64 : public DisplayMono {

printText(mFmtText, l_TotalPower, 0xff);
} else {
printText("offline", l_TotalPower, 0xff);
printText(STR_OFFLINE, l_TotalPower, 0xff);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/Display/Display_Mono_84X48.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DisplayMono84X48 : public DisplayMono {

// print Date and time
if (0 != mDisplayData->utcTs)
printText(ah::getDateTimeStrShort(mDisplayData->utcTs).c_str(), l_Time, 0xff);
printText(ah::getDateTimeStrShort_i18n(mDisplayData->utcTs).c_str(), l_Time, 0xff);

if (showLine(l_Status)) {
// alternatively:
Expand All @@ -90,7 +90,7 @@ class DisplayMono84X48 : public DisplayMono {
// print status of inverters
else {
if (0 == mDisplayData->nrSleeping + mDisplayData->nrProducing)
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "no inverter");
snprintf(mFmtText, DISP_FMT_TEXT_LEN, STR_NO_INVERTER);
else if (0 == mDisplayData->nrSleeping)
snprintf(mFmtText, DISP_FMT_TEXT_LEN, "\x86"); // sun symbol
else if (0 == mDisplayData->nrProducing)
Expand All @@ -111,7 +111,7 @@ class DisplayMono84X48 : public DisplayMono {

printText(mFmtText, l_TotalPower, 0xff);
} else {
printText("offline", l_TotalPower, 0xff);
printText(STR_OFFLINE, l_TotalPower, 0xff);
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/plugins/plugin_lang.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//-----------------------------------------------------------------------------
// 2024 Ahoy, https://ahoydtu.de
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------

#ifndef __PLUGIN_LANG_H__
#define __PLUGIN_LANG_H__

#ifdef LANG_DE
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFebMrzAprMaiJunJulAugSepOktNovDez"
#define STR_DAYNAME_3_CHAR_LIST "ErrSonMonDieMitDonFreSam"
#define STR_OFFLINE "aus"
#define STR_NO_INVERTER "kein inverter"
#elif LANG_FR
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFevMarAvrMaiJunJulAouSepOctNovDec"
#define STR_DAYNAME_3_CHAR_LIST "ErrDimLunMarMerJeuVenSam"
#define STR_OFFLINE "eteint"
#define STR_NO_INVERTER "pas d'onduleur"
#else
#define STR_MONTHNAME_3_CHAR_LIST "ErrJanFebMarAprMayJunJulAugSepOctNovDec"
#define STR_DAYNAME_3_CHAR_LIST "ErrSunMonTueWedThuFriSat"
#define STR_OFFLINE "offline"
#define STR_NO_INVERTER "no inverter"
#endif

#endif /*__PLUGIN_LANG_H__*/
32 changes: 32 additions & 0 deletions src/utils/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "helper.h"
#include "dbg.h"
#include "../plugins/plugin_lang.h"

namespace ah {
void ip2Arr(uint8_t ip[], const char *ipStr) {
Expand Down Expand Up @@ -82,6 +83,37 @@ namespace ah {
return String(str);
}

#define dt_SHORT_STR_LEN_i18n 3 // the length of short strings
static char buffer[dt_SHORT_STR_LEN_i18n + 1]; // must be big enough for longest string and the terminating null
const char monthShortNames_P[] PROGMEM = STR_MONTHNAME_3_CHAR_LIST;
const char dayShortNames_P[] PROGMEM = STR_DAYNAME_3_CHAR_LIST;
char* monthShortStr_i18n(uint8_t month)
{
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
buffer[i] = pgm_read_byte(&(monthShortNames_P[i + month * dt_SHORT_STR_LEN_i18n]));
buffer[dt_SHORT_STR_LEN_i18n] = 0;
return buffer;
}

char* dayShortStr_i18n(uint8_t day)
{
for (int i=0; i < dt_SHORT_STR_LEN_i18n; i++)
buffer[i] = pgm_read_byte(&(dayShortNames_P[i + day * dt_SHORT_STR_LEN_i18n]));
buffer[dt_SHORT_STR_LEN_i18n] = 0;
return buffer;
}

String getDateTimeStrShort_i18n(time_t t) {
char str[20];
if(0 == t)
sprintf(str, "n/a");
else {
sprintf(str, "%3s ", dayShortStr_i18n(dayOfWeek(t)));
sprintf(str+4, "%2d.%3s %02d:%02d", day(t), monthShortStr_i18n(month(t)), hour(t), minute(t));
}
return String(str);
}

uint64_t Serial2u64(const char *val) {
char tmp[3];
uint64_t ret = 0ULL;
Expand Down
1 change: 1 addition & 0 deletions src/utils/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace ah {
double round3(double value);
String getDateTimeStr(time_t t);
String getDateTimeStrShort(time_t t);
String getDateTimeStrShort_i18n(time_t t);
String getDateTimeStrFile(time_t t);
String getTimeStr(time_t t);
String getTimeStrMs(uint64_t t);
Expand Down
45 changes: 34 additions & 11 deletions src/web/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,91 @@

#ifdef LANG_DE
#define REBOOT_ESP_APPLY_CHANGES "starte AhoyDTU neu, um die Änderungen zu speichern"
#else /*LANG_EN*/
#elif LANG_FR
#define REBOOT_ESP_APPLY_CHANGES "redémarrer AhoyDTU pour appliquer tous vos changements de configuration"
#else
#define REBOOT_ESP_APPLY_CHANGES "reboot AhoyDTU to apply all your configuration changes"
#endif

#ifdef LANG_DE
#define TIME_NOT_SET "keine gültige Zeit, daher keine Kommunikation zum Wechselrichter möglich"
#else /*LANG_EN*/
#elif LANG_FR
#define TIME_NOT_SET "heure non définie. Aucune communication avec l'onduleur possible"
#else
#define TIME_NOT_SET "time not set. No communication to inverter possible"
#endif

#ifdef LANG_DE
#define WAS_IN_CH_12_TO_14 "Der ESP war in WLAN Kanal 12 bis 14, was uU. zu Abstürzen führt"
#else /*LANG_EN*/
#elif LANG_FR
#define WAS_IN_CH_12_TO_14 "Votre ESP était sur les canaux wifi 12 à 14. Cela peut entraîner des redémarrages de votre AhoyDTU"
#else
#define WAS_IN_CH_12_TO_14 "Your ESP was in wifi channel 12 to 14. It may cause reboots of your AhoyDTU"
#endif

#ifdef LANG_DE
#define PATH_NOT_FOUND "Pfad nicht gefunden: "
#else /*LANG_EN*/
#elif LANG_FR
#define PATH_NOT_FOUND "Chemin introuvable : "
#else
#define PATH_NOT_FOUND "Path not found: "
#endif

#ifdef LANG_DE
#define INCOMPLETE_INPUT "Unvollständige Eingabe"
#else /*LANG_EN*/
#elif LANG_FR
#define INCOMPLETE_INPUT "Saisie incomplète"
#else
#define INCOMPLETE_INPUT "Incomplete input"
#endif

#ifdef LANG_DE
#define INVALID_INPUT "Ungültige Eingabe"
#else /*LANG_EN*/
#elif LANG_FR
#define INVALID_INPUT "Saisie invalide"
#else
#define INVALID_INPUT "Invalid input"
#endif

#ifdef LANG_DE
#define NOT_ENOUGH_MEM "nicht genügend Speicher"
#else /*LANG_EN*/
#elif LANG_FR
#define NOT_ENOUGH_MEM "Mémoire insuffisante"
#else
#define NOT_ENOUGH_MEM "Not enough memory"
#endif

#ifdef LANG_DE
#define DESER_FAILED "Deserialisierung fehlgeschlagen"
#else /*LANG_EN*/
#elif LANG_FR
#define DESER_FAILED "Échec de la désérialisation"
#else
#define DESER_FAILED "Deserialization failed"
#endif

#ifdef LANG_DE
#define INV_NOT_FOUND "Wechselrichter nicht gefunden!"
#else /*LANG_EN*/
#elif LANG_FR
#define INV_NOT_FOUND "onduleur non trouvé !"
#else
#define INV_NOT_FOUND "inverter not found!"
#endif

#ifdef LANG_DE
#define FACTORY_RESET "Ahoy auf Werkseinstellungen zurücksetzen"
#else /*LANG_EN*/
#elif LANG_FR
#define FACTORY_RESET "Réinitialisation d'usine d'Ahoy"
#else
#define FACTORY_RESET "Ahoy Factory Reset"
#endif

#ifdef LANG_DE
#define BTN_REBOOT "Ahoy neustarten"
#else /*LANG_EN*/
#elif LANG_FR
#define BTN_REBOOT "Redémarrer"
#else
#define BTN_REBOOT "Reboot"
#endif

#endif /*__LANG_H__*/

Loading