Skip to content

Date and number localization #2207

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

Merged
merged 11 commits into from
Dec 18, 2017
1 change: 0 additions & 1 deletion dist/plotly-locale-en-us.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/plotly-locale-en.js

This file was deleted.

6 changes: 0 additions & 6 deletions lib/index-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ Plotly.register([
require('./pie')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-cartesian.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,4 @@ Plotly.register([
require('./violin')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ Plotly.register([
require('./candlestick')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ Plotly.register([
require('./choropleth')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-gl2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,4 @@ Plotly.register([
require('./parcoords')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-gl3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,4 @@ Plotly.register([
require('./mesh3d')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index-mapbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,4 @@ Plotly.register([
require('./scattermapbox')
]);

// locales
Plotly.register([
require('./locale-en'),
require('./locale-en-us')
]);

module.exports = Plotly;
6 changes: 0 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,4 @@ Plotly.register([
require('./calendars')
]);

// locales
Plotly.register([
require('./locale-en.js'),
require('./locale-en-us.js')
]);

module.exports = Plotly;
6 changes: 6 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ exports.register([
require('./components/rangeselector')
]);

// locales en and en-US are required for default behavior
exports.register([
require('./locale-en'),
require('./locale-en-US')
]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎩 bundle_tests/core_test 🌟

Since we're constructing our own d3.locale now no matter what, locale-en needs to be part of the core so it can be used as the fallback for missing pieces of other locales. Then for simplicity I moved the default locale-en-US to the core as well, which has the nice side-effect of keeping these redundant locales out of dist/.

@etpinard seem reasonable? Are you OK with putting these two in the root src/ directory? At least as long as we're not going to put any other locales into the core it doesn't seem like they warrant their own directory.

Minor downside is the lib/index* files don't demonstrate how to register locales, but we should be able to to better than documenting it there anyhow - somewhere we will want examples of how to use locales both in the build process and via script tags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard seem reasonable?

This is very reasonable 👌

but we should be able to to better than documenting it there anyhow

Yep, we should at least open up an issue on https://github.com/plotly/documentation/issues and / or add a Locale section to dist/README.md via tasks/stats.js.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated dist/README.md -> 331b2da

will open an issue at https://github.com/plotly/documentation once this is merged.


// plot icons
exports.Icons = require('../build/ploticon');

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tasks/pull_date_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var common = require('./util/common');
var args = process.argv.slice(2);
var argLocale = args[0];

var pathToEn = path.join(constants.pathToLib, 'locale-en.js');
var pathToEn = path.join(constants.pathToSrc, 'locale-en.js');
var pathToWCRegions = path.join(__dirname, '../node_modules/world-calendars/dist/regional');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.join(require.resolve('world-calendars'), 'dist', 'regional')

would be a bit more robust

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, I didn't know about require.resolve - took a little fiddling but -> d0e0158


if(!argLocale) {
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/plots_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('Test Plots', function() {
layoutOut,
expected;

var formatObj = require('@lib/locale-en').format;
var formatObj = require('@src/locale-en').format;

function supplyLayoutDefaults(layoutIn, layoutOut) {
layoutOut._dfltTitle = {
Expand Down