Skip to content

Localization #2195

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 22 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7e075f5
localization routine and tests
alexcjohnson Dec 6, 2017
9a9de77
remove zsmooth that doesn't apply to contourcarpet
alexcjohnson Dec 6, 2017
d859de5
wrap all displayed strings in localize
alexcjohnson Dec 6, 2017
7d057e5
task to collect translation keys and verify syntax
alexcjohnson Dec 6, 2017
8a5eeec
looser placeholder check in titles
alexcjohnson Dec 7, 2017
03dcb5d
lint
alexcjohnson Dec 7, 2017
bf2c6db
move colons into the translations
alexcjohnson Dec 7, 2017
04ed6f0
set default locale to en-US and build this into the library
alexcjohnson Dec 8, 2017
0f8520e
turn log level 1 on by default and move zsmooth messages to logs
alexcjohnson Dec 8, 2017
5d6f267
take <br> out of notifier messages
alexcjohnson Dec 8, 2017
97c0898
include file & line number with translation keys
alexcjohnson Dec 8, 2017
daf0884
disable logging in image server
alexcjohnson Dec 8, 2017
4b48038
convert locales to json, only en(US)? in bundles, and build all local…
alexcjohnson Dec 8, 2017
4b8f980
move geo missing id warn -> log
alexcjohnson Dec 8, 2017
1275661
convert locales back into js instead of json
alexcjohnson Dec 8, 2017
fc03cce
change "unable to bind..." warning to a log
alexcjohnson Dec 8, 2017
cb2f00c
fix command test for warn -> log
alexcjohnson Dec 8, 2017
97821e9
tweak a few of the string literals for consistency
alexcjohnson Dec 8, 2017
e80ec91
fix sankey test and clean log messages from other tests
alexcjohnson Dec 8, 2017
8b9e7d8
remove invalid data from geo_choropleth-text.json
alexcjohnson Dec 8, 2017
6029f94
update finance test for lowercase labels
alexcjohnson Dec 8, 2017
9708b56
update select_test for choropleth mock change
alexcjohnson Dec 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/index-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ Plotly.register([
require('./pie')
]);

// locales
Plotly.register(require('./locales.js'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would better to put these Plotly.register calls in src/core.js so that we don't have to duplicate them?

That would also mean moving locale modules to a new src/locales/ directory, as we wouldn't want to require lib/ files from src/ right?


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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

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

// locales
Plotly.register(require('./locales.js'));

module.exports = Plotly;
17 changes: 17 additions & 0 deletions lib/locale-en-us.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
moduleType: 'locale',
name: 'en-US',
dictionary: {
'Click to enter Colorscale title': 'Click to enter Colorscale title'
}
};
17 changes: 17 additions & 0 deletions lib/locale-en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
moduleType: 'locale',
name: 'en',
dictionary: {
'Click to enter Colorscale title': 'Click to enter Colourscale title'
}
};
14 changes: 14 additions & 0 deletions lib/locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I think registering only one local (en-US) in the dist bundles should suffice, but then again as only the spelling of colo(u)rscale differs between the two, including both en and en-US is fine by me 👌

require('./locale-en.js'),
require('./locale-en-us.js')
];
2 changes: 1 addition & 1 deletion src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ module.exports = {

// Which localization should we use?
// Should be a string like 'en' or 'en-US'.
locale: 'en',
locale: 'en-US',

// Localization dictionaries
// Dictionaries can be provided either here (specific to one chart) or globally
Expand Down