[GH-ISSUE #1408] strings_en.h when using WIFI_MANAGER_OVERRIDE_STRINGS how to include mystrings_en.h #1205

Closed
opened 2026-02-28 01:29:01 +03:00 by kerem · 19 comments
Owner

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

-iquote my_strings_dir
-D WIFI_MANAGER_OVERRIDE_STRINGS
-include myStrings_en.h

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

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 -iquote my_strings_dir -D WIFI_MANAGER_OVERRIDE_STRINGS -include myStrings_en.h 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
kerem 2026-02-28 01:29:01 +03:00
Author
Owner

@tablatronix commented on GitHub (May 3, 2022):

-DWIFI_MANAGER_OVERRIDE_STRINGS
?

<!-- gh-comment-id:1116185529 --> @tablatronix commented on GitHub (May 3, 2022): -DWIFI_MANAGER_OVERRIDE_STRINGS ?
Author
Owner

@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

<!-- gh-comment-id:1116787246 --> @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
Author
Owner

@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>

<!-- gh-comment-id:1116845977 --> @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>
Author
Owner

@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

<!-- gh-comment-id:1118396139 --> @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
Author
Owner

@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

<!-- gh-comment-id:1118407811 --> @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
Author
Owner

@tablatronix commented on GitHub (May 5, 2022):

Ill add a filename directive

did you try include "" instead

<!-- gh-comment-id:1118534701 --> @tablatronix commented on GitHub (May 5, 2022): Ill add a filename directive did you try include "" instead
Author
Owner

@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

<!-- gh-comment-id:1118544870 --> @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
Author
Owner

@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

<!-- gh-comment-id:1118569820 --> @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
Author
Owner

@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".

<!-- gh-comment-id:1126398462 --> @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"._
Author
Owner

@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:

const char *WM_VERSION_STR PROGMEM = "v1.0.11-strings_en";

};

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;

<!-- gh-comment-id:1126796080 --> @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 = "<!DOCTYPE html>" "<html lang='en'><head>" "<meta name='format-detection' content='telephone=no'>" "<meta charset='UTF-8'>" "<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>" "<title>{v}</title>"; } strings_en.h class Strings : public StringBase { public: const char *WM_VERSION_STR PROGMEM = "v1.0.11-strings_en"; }; 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;
Author
Owner

@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.

<!-- gh-comment-id:1206016016 --> @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.
Author
Owner

@ben700 commented on GitHub (Aug 5, 2022):

Yes

On Fri, 5 Aug 2022, 05:00 Camilo Cáceres, @.***> wrote:

Hello @ben700 https://github.com/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.


Reply to this email directly, view it on GitHub
https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:1206807220 --> @ben700 commented on GitHub (Aug 5, 2022): Yes On Fri, 5 Aug 2022, 05:00 Camilo Cáceres, ***@***.***> wrote: > Hello @ben700 <https://github.com/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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@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:

Hello @ben700 https://github.com/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.


Reply to this email directly, view it on GitHub
https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:1206810900 --> @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: > Hello @ben700 <https://github.com/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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@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:

Hello @ben700 https://github.com/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.


Reply to this email directly, view it on GitHub
https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

<!-- gh-comment-id:1206820551 --> @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: > Hello @ben700 <https://github.com/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. > > — > Reply to this email directly, view it on GitHub > <https://github.com/tzapu/WiFiManager/issues/1408#issuecomment-1206016016>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA5Z555HATZPHJBG2UC4HQLVXSGUTANCNFSM5U7CM5QQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@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

<!-- gh-comment-id:1209975168 --> @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
Author
Owner

@tablatronix commented on GitHub (Aug 9, 2022):

https://github.com/tzapu/WiFiManager/pull/1474

<!-- gh-comment-id:1209986830 --> @tablatronix commented on GitHub (Aug 9, 2022): https://github.com/tzapu/WiFiManager/pull/1474
Author
Owner

@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 /include folder), give it a custom name, eg include/wm_custom.h and comment out these two lines:

//#ifndef WIFI_MANAGER_OVERRIDE_STRINGS 

and

// END WIFI_MANAGER_OVERRIDE_STRINGS
//#endif //<--- comment this one 

Make you changes in this file.

Then add these build flags to your platformio.ini file:

build_flags = -DWIFI_MANAGER_OVERRIDE_STRINGS
			  -iquote include
			  '-D WM_STRINGS_FILE="wm_custom.h"'
<!-- gh-comment-id:1470947278 --> @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 `/include` folder), give it a custom name, eg `include/wm_custom.h` and comment out these two lines: ```c //#ifndef WIFI_MANAGER_OVERRIDE_STRINGS ``` and ```c // END WIFI_MANAGER_OVERRIDE_STRINGS //#endif //<--- comment this one ``` Make you changes in this file. Then add these build flags to your `platformio.ini` file: ``` build_flags = -DWIFI_MANAGER_OVERRIDE_STRINGS -iquote include '-D WM_STRINGS_FILE="wm_custom.h"' ```
Author
Owner

@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

<!-- gh-comment-id:1471135847 --> @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
Author
Owner

@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

<!-- gh-comment-id:1471162741 --> @tablatronix commented on GitHub (Mar 16, 2023): `build_flags = -DWM_DEBUG_PORT=Serial -DWM_DEBUG_LEVEL=4 -DWM_STRINGS_FILE="\"wm_strings_es.h\""` 4c0d7fa77780558ee058ce5335a6bb585db96fd9
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1205
No description provided.