Open TenThumbsWPG opened 1 month ago
My first thought is something you could try right now: to change the format with Javascript after the page is rendered. You could do something like get the css selector for the element with the date, parse it, change the locale, then update the element.
You can add arbitrary Javascript to your Folium map. I’m on mobile now so don’t have a link for you, but there are examples in our Isssues, maybe also docs.
For a more clean solution, having the locale as option when creating a choropleth, or as an argument on colormap… I’m not sure right now, could be interesting. Probably exposing it on colormap in the Branca library is the way to go for that. Choropleth is already quite crowded so I wouldn’t add more arguments there, but through the choropleth object more advanced users could access the colormap object.
We don’t really have dev capacity, so if you manage to find something that works for you please share it here :)
I have looked at the HTML generated. There are a few things I can do for the
We would like to use folium to create choropleths in more than one language. So far (unless I am missing something), it appears that folium is using the system localization to set the language format for numbers in folium legend.
We, and I anticipate others, have more than one use for these maps: 1) Online as the intended HTML output 2) Print versions (digitally as images, parts of PDF files and also hard copies).
The problem is that in order to change number formats (in this case comma vs. period for decimal), the language localization needs to be reset globally, in most cases requiring a kernel reset (again, unless I am missing something).
I would like to be able to pass a number format to the legend to change the language format of the numbers in the scale, either by: 1) passing a format string, or 2) specifying a localization that folium can then reference and set the text accordingly 3) Have some documentation on how to inject an equivalent instruction by HTML.
Ultimately, I would like to do the following in a single code execution: 1) Create folium map (language localization unimportant since the html will use the localization of the system it is hosted on) 2) Change/re-render choropleths to two languages (with number formats) so that images can be saved for alternate media use
Since headerless browser can be used to generate images and text can be passed in any language, the only thing that is needed is to interact with the format of the numbers in the legend scale.