write_html: locale config does not work
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Hi!
I'm using plotly to generate a standalone HTML-file that contains only my plot. I do want the axes to be localized in German (one axis has Dates).
This code does not work:
fig.write_html("index.html",
include_plotlyjs="cdn",
config={"locale": "de"}
)
The reason is that the following line is missing in the generated HTML-file (cf. plotly.js documentation)
<script src="https://cdn.plot.ly/plotly-locale-de-latest.js"></script>
I suggest to add a locale argument to the write_html function that does two things (think of de as exchangeable):
- it adds the missing localization file somewhere here
- it adds
"locale": "de"to the plotconfig
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/python/plotly/plotly/io/_html.py around line 345 and trace how write_html builds the standalone HTML and plot configuration. Verify the example with a German locale, then ensure the generated document loads the locale script and applies the requested locale to the plot configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, python
- Domain
- data-visualization, web-dev
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100