-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add support for i18next localisation library #194
Conversation
Thanks for your contribution (which is really appreciated) but I've two things to mention: b) ESPuino uses a custom flash partition-layout (https://github.com/biologist79/ESPuino/blob/master/custom_16mb_ota.csv). I'm not familiar with LittleFS so I'm not sure what it takes partition-wise. That being said: it's no option if changes to this layout are necessary as this has a really big impact (ESPuino is already used by hundrets of users). |
Hi, Add b) in the 16mb parition, you have the partition named "spiffs" (with a size of 0x330000 bytes ~3MB). Thats the internal file system of the esp. It can be formatted and used either with spiffs (not recommended) or littleFS and files written there can be accessed just like the files on the sd-card. In my projects I mostly use them for saving configuration (not a usecase here, since you use nvs). For static web pages, one can either put them into the image itself (like you are currently doing with PROGMEM). One point would be to compress the files before wirting them to the flash to save space and bandwith (so basically you are wirting the gzipped files into the esp, but then you can not templates since for the webserver they seem like a binary blobb). My first try with python was semi successfull, but with nodeJS it will be way easier. I've already registered at the Forum (my native tongue is german), it just takes time to get used to it and navigate in there, there is tons a of information (not a bad thing ;) ). |
@laszloh Just a note: |
I've added the files to the PROGMEM. Compiling and comparing the master branch against my branch. The results: master:
i18n:
The increase comes from the embedding of the 3 js libraries needed for i18next and it's supprting libraries. The main question is, if the increase is ok. If not, I could link to cdn (like with the other js-libraries). Then we'd only see a small increase due to the json files needed for the translations (about 5k). On the downside the access point would not get any translation (or someone would have to write a really basic i18n engine for it). The code itself is still untested, unfortunately I did not find time to do it yet. |
WIP... untested until now
Add the express server and make it provide the html and other necessary files.
Use LocalStorage to save the value modified by the user
currently it's a copy of the englisch one
Rebase on the current master finished. I've tested it on my setup, it work in both accesspoint and normal operation mode. |
Tried it but no text is shown. |
Hi, biologist79, I had only embedded the javascript libraries needed for the translation engine (since they are not avaliable at the first setup, when the ESP32 is in AP mode). Everything else is still fetched externally. If I embedd them, it will cost about 400kB flash space to embedd them. I would rather try to make the espuino-ui work, on the long run that seems like a better idear, since it optimizes the build (by striping unused javascript functions and embedding everything into a single compressed file). |
Sorry, thought all libs would be part of the new FW. However, I'm with how it's done currently. Thanks for your contribution! |
Can confirm space between buttons could be "way" more. However: like it 👍 |
Fix bug where the browser cache prevented the fetching of new files.
Add whitespaces between buttons, which dissapeared when minifying the html files. Add translations to the context menu of the file browser.
Flickering should be reduced/fixed. I did not find any better soultion than putting some of the texts back in to prevent the design shifting due to delayed i18n loading. |
Found some minor issues: a) Space is missing between "Steuerung" and its icon. Thanks for your work - really appreciate it! |
Done, I also found some other text's in the file upload part which I translated. |
a) ok c) Now messages appear like "toast.rfidDetect" or "toast.success" :-) |
I've disabled the cache since it seems that firefox is not sending the required headers (I don't know why). Please try reloading with CTRL+F5 after compiling with the last commit to clear the browser cache. |
Merged, finally :-) |
Add support for i18next localisation library (biologist79#194)
Hi, can you tell me how to convert the files to get them to the "dist" folder if I modified some files in the "html" folder? |
Would have expected (but didn't test) this works automatically when doing a build. @laszloh Please fix. |
@Joe91 @biologist79 I knew I had forgotten about something. I did the compression of the files manually (so creating the minifed version & the zips), since I had not found a good python html minifier. Finding a minifier, which I could get to work was a real pia, but at last I found one, which seems to work with the setup. Should I create a pull request, or can you directly merge fef0288? |
No, I don't need a PR. Can fetch this directly by cherry-picking. |
Playing around with i18next as localization agent. Idea extracted into own branch from webpage optimisation.
This pull request is currently untested.
ToDo List: