Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0545e2

Browse filesBrowse files
committed
improve docs on loading and applying locales
1 parent 253212d commit d0545e2
Copy full SHA for d0545e2

File tree

Expand file treeCollapse file tree

2 files changed

+31
-17
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+31
-17
lines changed

‎dist/README.md

Copy file name to clipboardExpand all lines: dist/README.md
+15-8Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,32 @@ You can grab the relevant MathJax files in `./dist/extras/mathjax/`.
3636
### To include localization
3737

3838
Plotly.js defaults to US English (en-US) and includes British English (en) in the standard bundle.
39-
Many other localizations are available - here is an example using Swiss-German (de-CH),
40-
see the contents of this directory for the full list.
41-
They are also available on our CDN as https://cdn.plot.ly/plotly-locale-de-ch-latest.js OR https://cdn.plot.ly/plotly-locale-de-ch-1.38.1.js
42-
Note that the file names are all lowercase, even though the region is uppercase when you apply a locale.
39+
This example uses Swiss-German (de-CH), but many other localizations are available (see the contents of this directory for the full list). All available locales have working date localizations, but only a subset will localize on-graph text (e.g., modebar controls). See [here](https://github.com/plotly/plotly.js/pulls?q=is%3Apr+label%3A%22type%3A+translation%22+is%3Aclosed) for a list of "fully-supported" locales.
4340

44-
*After* the plotly.js script tag, add:
41+
#### Loading and registering locales
42+
43+
Some locales build on other locales (e.g., "de-CH" builds on "de"). In this case, first load the base locale (e.g., "de"), then load the actual locale (e.g., "de-CH"):
4544

4645
```html
46+
<script src="plotly-locale-de.js"></script>
4747
<script src="plotly-locale-de-ch.js"></script>
48+
```
49+
50+
Locale bundles are also available on our CDN (e.g., https://cdn.plot.ly/plotly-locale-de-ch-latest.js OR https://cdn.plot.ly/plotly-locale-de-ch-1.38.1.js). Note that the file names here are all lowercase, but the region is uppercase when you apply a locale.
51+
52+
#### Apply a locale
53+
54+
After registering a locale, you can it as the default for all Plotly plots:
55+
56+
```html
4857
<script>Plotly.setPlotConfig({locale: 'de-CH'})</script>
4958
```
5059

51-
The first line loads and registers the locale definition with plotly.js, the second sets it as the default for all Plotly plots.
52-
You can also include multiple locale definitions and apply them to each plot separately as a `config` parameter:
60+
Or, apply the (registered) locale to particular plot(s) as a `config` parameter:
5361

5462
```js
5563
Plotly.newPlot(graphDiv, data, layout, {locale: 'de-CH'})
5664
```
57-
5865
# Bundle information
5966

6067
The main plotly.js bundle includes all the official (non-beta) trace modules.

‎tasks/stats.js

Copy file name to clipboardExpand all lines: tasks/stats.js
+16-9Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,32 @@ function getInfoContent() {
7070
'### To include localization',
7171
'',
7272
'Plotly.js defaults to US English (en-US) and includes British English (en) in the standard bundle.',
73-
'Many other localizations are available - here is an example using Swiss-German (de-CH),',
74-
'see the contents of this directory for the full list.',
75-
'They are also available on our CDN as ' + cdnRoot + 'locale-de-ch-latest.js OR ' + cdnRoot + 'locale-de-ch-' + pkg.version + '.js',
76-
'Note that the file names are all lowercase, even though the region is uppercase when you apply a locale.',
73+
'This example uses Swiss-German (de-CH), but many other localizations are available (see the contents of this directory for the full list). All available locales have working date localizations, but only a subset will localize on-graph text (e.g., modebar controls). See [here](https://github.com/plotly/plotly.js/pulls?q=is%3Apr+label%3A%22type%3A+translation%22+is%3Aclosed) for a list of "fully-supported" locales.',
7774
'',
78-
'*After* the plotly.js script tag, add:',
75+
'#### Loading and registering locales',
76+
'',
77+
'Some locales build on other locales (e.g., "de-CH" builds on "de"). In this case, first load the base locale (e.g., "de"), then load the actual locale (e.g., "de-CH"):',
7978
'',
8079
'```html',
80+
'<script src="plotly-locale-de.js"></script>',
8181
'<script src="plotly-locale-de-ch.js"></script>',
82+
'```',
83+
'',
84+
'Locale bundles are also available on our CDN (e.g., ' + cdnRoot + 'locale-de-ch-latest.js OR ' + cdnRoot + 'locale-de-ch-' + pkg.version + '.js). Note that the file names here are all lowercase, but the region is uppercase when you apply a locale.',
85+
'',
86+
'#### Apply a locale',
87+
'',
88+
'After registering a locale, you can it as the default for all Plotly plots:',
89+
'',
90+
'```html',
8291
'<script>Plotly.setPlotConfig({locale: \'de-CH\'})</script>',
8392
'```',
8493
'',
85-
'The first line loads and registers the locale definition with plotly.js, the second sets it as the default for all Plotly plots.',
86-
'You can also include multiple locale definitions and apply them to each plot separately as a `config` parameter:',
94+
'Or, apply the (registered) locale to particular plot(s) as a `config` parameter:',
8795
'',
8896
'```js',
8997
'Plotly.newPlot(graphDiv, data, layout, {locale: \'de-CH\'})',
90-
'```',
91-
''
98+
'```'
9299
];
93100
}
94101

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.