mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1408] strings_en.h when using WIFI_MANAGER_OVERRIDE_STRINGS how to include mystrings_en.h #1205
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1205
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ben700 on GitHub (May 3, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1408
I was expecting to be able to do something like
I've tried #include in main.cpp
Can you not add two lines in strings_en.h as below
#ifdef WIFI_MANAGER_OVERRIDE_STRINGS
#include WIFI_MANAGER_OVERRIDE_STRINGS
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
@tablatronix commented on GitHub (May 3, 2022):
-DWIFI_MANAGER_OVERRIDE_STRINGS
?
@ben700 commented on GitHub (May 4, 2022):
So adding
-DWIFI_MANAGER_OVERRIDE_STRINGS
Stops the strings being included from strings_en.h but then I need to include the new versions of the strings say that file is called myStrings_en.h and stored in my_strings_dir
That's why I expected this to work:-
-iquote my_strings_dir
-D WIFI_MANAGER_OVERRIDE_STRINGS
-include myStrings_en.h
@tablatronix commented on GitHub (May 4, 2022):
you cannot include from a directory afaik, so just name it different
platformio.ini
build_flags = -DWIFI_MANAGER_OVERRIDE_STRINGS (NO SPACE)
main
#include <strings_es.h>
@ben700 commented on GitHub (May 5, 2022):
platformio.ini
build_flags = -DWIFI_MANAGER_OVERRIDE_STRINGS (NO SPACE)
main
#include <strings_es.h>
Error
arduinoespressif8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h:31,
from .pio/libdeps/droneInstall/WiFiManager/WiFiManager.h:81,
from .pio/libdeps/droneInstall/WiFiManager/WiFiManager.cpp:13:
.pio/libdeps/droneInstall/WiFiManager/WiFiManager.h:525:51: error: 'S_brand' was not declared in this scope; did you mean 'srand'?
525 | String _title = FPSTR(S_brand); // app title - default WiFiManager
@ben700 commented on GitHub (May 5, 2022):
Adding these lines to strings_en.h works but not when I add to main.cpp
Solution 1
strings_en.h
#ifdef WIFI_MANAGER_OVERRIDE_STRINGS
#include "strings_es.h"
#endif
Obviously I don't want to make any changes in WiFiManager so it can be automatically built by Cloud Build when I tag in github
Solution 2
platformio.ini
build_flags = -DWIFI_MANAGER_OVERRIDE_STRINGS = strings_es.h
strings_en.h
#ifdef WIFI_MANAGER_OVERRIDE_STRINGS
#include WIFI_MANAGER_OVERRIDE_STRINGS
#endif
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
@tablatronix commented on GitHub (May 5, 2022):
Ill add a filename directive
did you try include "" instead
@ben700 commented on GitHub (May 5, 2022):
Yes,
https://github.com/ben700/WiFiManager_1408 I'll tag files so you know we have same understanding
@ben700 commented on GitHub (May 5, 2022):
https://github.com/ben700/WiFiManager_1408/tree/add-include
In strings_en if you change the line 16 i think
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
to
#ifdef WIFI_MANAGER_OVERRIDE_STRINGS
#include WIFI_MANAGER_OVERRIDE_STRINGS
#else
and use
'-DWIFI_MANAGER_OVERRIDE_STRINGS="strings_es.h"'
That would reduce people like me asking
@georgevbsantiago commented on GitHub (May 13, 2022):
Hi, I'm also researching the best strategy to translate the content of "strings_en.h" to Portuguese/Brazil with a "strings_pt-br.h".
A strategy that:
Allow updating the html text, without changing the code of "strings_en.h";
The solution proposed by @ben700 solves this challenge.
Do not cause a bug, if "strings_en.h" adds a new html text, which is not foreseen in "strings_pt-br.h".
I don't know if there is a strategy to avoid this bug. One option would be WiFiManager to preserve the original text of "strings_en.h", in case a substitute text is not defined in "strings_pt-br.h". If there's a way to do that, it wouldn't cause bugs in a future update. The developer would only have to update the text.
But I don't know if it's a good strategy, since an error caused by the compiler can be something desirable for the developer to update his code in "strings_pt-br.h".
@ben700 commented on GitHub (May 14, 2022):
Are you thinking something like
strings_base.h
class StringBase
{
public:
const char *WM_VERSION_STR PROGMEM = "v1.0.11-beta";
const char HTTP_HEAD_START[] PROGMEM = ""
"<html lang='en'><head>"
""
""
""
"";
}
strings_en.h
class Strings : public StringBase
{
public:
};
strings.h
#ifdef WIFI_MANAGER_OVERRIDE_STRINGS
#include WIFI_MANAGER_OVERRIDE_STRINGS
#else
#include "strings_en.h"
#endif
Strings *strings = new Strings();
const char *WM_VERSION_STR PROGMEM =strings->WM_VERSION_STR;
@camilo-sx commented on GitHub (Aug 5, 2022):
Hello @ben700 ! Did you manage to include "strings_en.h" properly?
I've seen your code but I still don't understand how you include that.
You have the same "strings_en.h" in src, wifi_strings and lib>WiFi_Manager folders so I'm a little confused.
When you use in platformio.ini :
build_flags =
-iquote wifi_strings
'-DWIFI_MANAGER_OVERRIDE_STRINGS="strings_es.h"'
Which file are you pointing to?
I would really appreciate your help if you could explain it to me simply c:
Thanks in advance.
@ben700 commented on GitHub (Aug 5, 2022):
Yes
On Fri, 5 Aug 2022, 05:00 Camilo Cáceres, @.***> wrote:
@ben700 commented on GitHub (Aug 5, 2022):
I couldn't get lipped to work so created my own folder called Wi-Fi strings.
Look at the tag add-include
https://github.com/ben700/WiFiManager_1408/tree/add-include
Ben
On Fri, 5 Aug 2022, 05:00 Camilo Cáceres, @.***> wrote:
@ben700 commented on GitHub (Aug 5, 2022):
In the repository there's two tags.
Master shoes as is.
https://github.com/ben700/WiFiManager_1408/tree/master
Add-include shows the change.
https://github.com/ben700/WiFiManager_1408/tree/add-include
Ben
On Fri, 5 Aug 2022, 05:00 Camilo Cáceres, @.***> wrote:
@tablatronix commented on GitHub (Aug 9, 2022):
I have a test branch i am working on a better solution, I will try to get it posted soon
@tablatronix commented on GitHub (Aug 9, 2022):
https://github.com/tzapu/WiFiManager/pull/1474
@raomin commented on GitHub (Mar 15, 2023):
Ouch... sorry but this clearly needs some documentation.
After quite some struggle, here is what I came with that seems to work.
In markdown so maybe it can be added to the Readme
##Customizing interface
All html is contained in a single file
wm_strings_en.h. To customize the html code, copy this file into your project folder (or the/includefolder), give it a custom name, eginclude/wm_custom.hand comment out these two lines:and
Make you changes in this file.
Then add these build flags to your
platformio.inifile:@tablatronix commented on GitHub (Mar 16, 2023):
you should not need to use WIFI_MANAGER_OVERRIDE_STRINGS at all now, you should remove that and you wont have an issue
I have an example i lost, i was going to upload a strings_es example etc
@tablatronix commented on GitHub (Mar 16, 2023):
build_flags = -DWM_DEBUG_PORT=Serial -DWM_DEBUG_LEVEL=4 -DWM_STRINGS_FILE="\"wm_strings_es.h\""4c0d7fa777