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 11 commits
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
56 changes: 56 additions & 0 deletions dist/translation-keys.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Autoscale // components/modebar/buttons.js:139
Box Select // components/modebar/buttons.js:103
Click to enter Colorscale title // plots/plots.js:437
Click to enter Component A title // plots/ternary/ternary.js:386
Click to enter Component B title // plots/ternary/ternary.js:400
Click to enter Component C title // plots/ternary/ternary.js:411
Click to enter Plot title // plot_api/plot_api.js:579
Click to enter X axis title // plots/plots.js:435
Click to enter Y axis title // plots/plots.js:436
Close: // traces/ohlc/transform.js:139
Compare data on hover // components/modebar/buttons.js:167
Double click on legend to isolate individual trace // components/legend/handle_click.js:90
Double-click to zoom back out // plots/cartesian/dragbox.js:299
Download plot as a png // components/modebar/buttons.js:52
Edit in Chart Studio // components/modebar/buttons.js:76
High: // traces/ohlc/transform.js:137
IE only supports svg. Changing format to svg. // components/modebar/buttons.js:60
Incoming flow count: // traces/sankey/plot.js:142
Lasso Select // components/modebar/buttons.js:112
Low: // traces/ohlc/transform.js:138
Open: // traces/ohlc/transform.js:136
Orbital rotation // components/modebar/buttons.js:279
Outgoing flow count: // traces/sankey/plot.js:143
Pan // components/modebar/buttons.js:94
Produced with Plotly // components/modebar/modebar.js:256
Reset // components/modebar/buttons.js:432
Reset axes // components/modebar/buttons.js:148
Reset camera to default // components/modebar/buttons.js:314
Reset camera to last save // components/modebar/buttons.js:322
Reset view // components/modebar/buttons.js:583
Reset views // components/modebar/buttons.js:529
Show closest data on hover // components/modebar/buttons.js:157
Snapshot succeeded // components/modebar/buttons.js:66
Sorry there was a problem downloading your snapshot! // components/modebar/buttons.js:69
Source: // traces/sankey/plot.js:140
Taking snapshot - this may take a few seconds // components/modebar/buttons.js:57
Target: // traces/sankey/plot.js:141
Toggle Spike Lines // components/modebar/buttons.js:548
Toggle show closest data on hover // components/modebar/buttons.js:353
Turntable rotation // components/modebar/buttons.js:288
Zoom // components/modebar/buttons.js:85
Zoom in // components/modebar/buttons.js:121
Zoom out // components/modebar/buttons.js:130
kde: // traces/violin/calc.js:73
lat: // traces/scattergeo/calc.js:48
lon: // traces/scattergeo/calc.js:49
lower fence: // traces/box/calc.js:134
max: // traces/box/calc.js:132
mean ± σ: // traces/box/calc.js:133
mean: // traces/box/calc.js:133
median: // traces/box/calc.js:128
min: // traces/box/calc.js:129
q1: // traces/box/calc.js:130
q3: // traces/box/calc.js:131
trace // plots/plots.js:439
upper fence: // traces/box/calc.js:135
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@etpinard @bpostlethwaite thoughts on this format, with the (first) source line for each key included for a translator to use for more context?

Also having all these strings together raises some questions about whether they're all actually what we want, or if any could be made more consistent:

  • Is the verb "Double-click" or "Double click"?
  • Most of the hover label names (the items ending in ':') are lowercase, but some (OHLC, sankey) are capitalized - is this what we want?
  • In making this PR I standardized the "Click to enter <item> title" ones to have <item> capitalized (previously one or two of them were lowercase) - is that correct?
  • Most of the Lib.notifier items have no punctuation but some of them do. Should we standardize?

Copy link
Contributor

Choose a reason for hiding this comment

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

thoughts on this format,

I like this format a lot. Nicely done 👌

Is the verb "Double-click" or "Double click"?

I have no preference.

Most of the hover label names (the items ending in ':') are lowercase, but some (OHLC, sankey) are capitalized - is this what we want?

I'd vote for standardizing to lower case.

I standardized the "Click to enter title" [...] is that correct?

fine by me.

Most of the Lib.notifier items have no punctuation but some of them do. Should we standardize?

No preference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made all the hover labels lower case, standardized on "Double-click" (when used as a verb, which is the only way we use it in plotly.js text), and tweaked a few other messages -> 97821e9

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')
];
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"bundle": "node tasks/bundle.js",
"header": "node tasks/header.js",
"stats": "node tasks/stats.js",
"build": "npm run preprocess && npm run bundle && npm run header && npm run stats",
"find-strings": "node tasks/find_locale_strings.js",
"build": "npm run preprocess && npm run find-strings && npm run bundle && npm run header && npm run stats",
"cibuild": "npm run preprocess && node tasks/cibundle.js",
"watch": "node tasks/watch.js",
"lint": "eslint --version && eslint .",
Expand All @@ -36,7 +37,7 @@
"test-image": "node tasks/test_image.js",
"test-image-gl2d": "node tasks/test_image.js gl2d_* --queue",
"test-export": "node tasks/test_export.js",
"test-syntax": "node tasks/test_syntax.js",
"test-syntax": "node tasks/test_syntax.js && npm run find-strings",
"test-bundle": "node tasks/test_bundle.js",
"test": "npm run test-jasmine && npm run test-bundle && npm run test-image && npm run test-image-gl2d && npm run test-syntax && npm run lint",
"start-test_dashboard": "node devtools/test_dashboard/server.js",
Expand Down
1 change: 0 additions & 1 deletion src/components/colorbar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ module.exports = overrideAll({
title: {
valType: 'string',
role: 'info',
dflt: 'Click to enter colorscale title',
description: 'Sets the title of the color bar.'
},
titlefont: fontAttrs({
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorbar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear',
{outerTicks: false, font: layout.font, noHover: true});

coerce('title');
coerce('title', layout._dfltTitle.colorbar);
Lib.coerceFont(coerce, 'titlefont', layout.font);
coerce('titleside');
};
2 changes: 1 addition & 1 deletion src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ module.exports = function draw(gd, id) {
propContainer: cbAxisOut,
propName: propName,
traceIndex: trace.index,
dfltName: 'colorscale',
placeholder: fullLayout._dfltTitle.colorbar,
containerGroup: container.select('.cbtitle')
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = function handleClick(g, gd, numClicks) {
}

if(numClicks === 1 && SHOWISOLATETIP && gd.data && gd._context.showTips) {
Lib.notifier('Double click on legend to isolate individual trace', 'long');
Lib.notifier(Lib._(gd, 'Double click on legend to isolate individual trace'), 'long');
SHOWISOLATETIP = false;
} else {
SHOWISOLATETIP = false;
Expand Down
Loading