WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

strings_en.h when using WIFI_MANAGER_OVERRIDE_STRINGS how to include mystrings_en.h

Open ben700 opened this issue 2 years ago • 16 comments

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

ben700 avatar May 03 '22 14:05 ben700

-DWIFI_MANAGER_OVERRIDE_STRINGS ?

tablatronix avatar May 03 '22 14:05 tablatronix

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

ben700 avatar May 04 '22 00:05 ben700

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>

tablatronix avatar May 04 '22 01:05 tablatronix

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 avatar May 05 '22 10:05 ben700

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

ben700 avatar May 05 '22 10:05 ben700

Ill add a filename directive

did you try include "" instead

tablatronix avatar May 05 '22 13:05 tablatronix

Yes,

https://github.com/ben700/WiFiManager_1408 I'll tag files so you know we have same understanding

ben700 avatar May 05 '22 13:05 ben700

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

ben700 avatar May 05 '22 13:05 ben700

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

georgevbsantiago avatar May 13 '22 19:05 georgevbsantiago

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 = "" "

" "" "" "" "{v}"; }

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;

ben700 avatar May 14 '22 19:05 ben700

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.

camilo-sx avatar Aug 05 '22 03:08 camilo-sx

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

ben700 avatar Aug 05 '22 19:08 ben700

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

ben700 avatar Aug 05 '22 20:08 ben700

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

ben700 avatar Aug 05 '22 20:08 ben700

I have a test branch i am working on a better solution, I will try to get it posted soon

tablatronix avatar Aug 09 '22 23:08 tablatronix

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

tablatronix avatar Aug 09 '22 23:08 tablatronix

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"'

raomin avatar Mar 15 '23 22:03 raomin

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 avatar Mar 16 '23 01:03 tablatronix

build_flags = -DWM_DEBUG_PORT=Serial -DWM_DEBUG_LEVEL=4 -DWM_STRINGS_FILE="\"wm_strings_es.h\""

4c0d7fa77780558ee058ce5335a6bb585db96fd9

tablatronix avatar Mar 16 '23 01:03 tablatronix