Skip to content

Commit d859de5

Browse files
committed
wrap all displayed strings in localize
1 parent 9a9de77 commit d859de5

File tree

30 files changed

+159
-106
lines changed

30 files changed

+159
-106
lines changed

src/components/colorbar/attributes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ module.exports = overrideAll({
177177
title: {
178178
valType: 'string',
179179
role: 'info',
180-
dflt: 'Click to enter colorscale title',
181180
description: 'Sets the title of the color bar.'
182181
},
183182
titlefont: fontAttrs({

src/components/colorbar/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
5959
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear',
6060
{outerTicks: false, font: layout.font, noHover: true});
6161

62-
coerce('title');
62+
coerce('title', layout._dfltTitle.colorbar);
6363
Lib.coerceFont(coerce, 'titlefont', layout.font);
6464
coerce('titleside');
6565
};

src/components/colorbar/draw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ module.exports = function draw(gd, id) {
455455
propContainer: cbAxisOut,
456456
propName: propName,
457457
traceIndex: trace.index,
458-
dfltName: 'colorscale',
458+
placeholder: fullLayout._dfltTitle.colorbar,
459459
containerGroup: container.select('.cbtitle')
460460
};
461461

src/components/legend/handle_click.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ module.exports = function handleClick(g, gd, numClicks) {
8787
}
8888

8989
if(numClicks === 1 && SHOWISOLATETIP && gd.data && gd._context.showTips) {
90-
Lib.notifier('Double click on legend to isolate individual trace', 'long');
90+
Lib.notifier(Lib._(gd, 'Double click on legend to isolate individual trace'), 'long');
9191
SHOWISOLATETIP = false;
9292
} else {
9393
SHOWISOLATETIP = false;

src/components/modebar/buttons.js

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var downloadImage = require('../../snapshot/download');
1717
var Icons = require('../../../build/ploticon');
1818

1919

20+
var _ = Lib._;
21+
2022
var modeBarButtons = module.exports = {};
2123

2224
/**
@@ -47,31 +49,31 @@ var modeBarButtons = module.exports = {};
4749

4850
modeBarButtons.toImage = {
4951
name: 'toImage',
50-
title: 'Download plot as a png',
52+
title: function(gd) { return _(gd, 'Download plot as a png'); },
5153
icon: Icons.camera,
5254
click: function(gd) {
5355
var format = 'png';
5456

55-
Lib.notifier('Taking snapshot - this may take a few seconds', 'long');
57+
Lib.notifier(_(gd, 'Taking snapshot - this may take a few seconds'), 'long');
5658

5759
if(Lib.isIE()) {
58-
Lib.notifier('IE only supports svg. Changing format to svg.', 'long');
60+
Lib.notifier(_(gd, 'IE only supports svg. Changing format to svg.'), 'long');
5961
format = 'svg';
6062
}
6163

6264
downloadImage(gd, {'format': format})
6365
.then(function(filename) {
64-
Lib.notifier('Snapshot succeeded - ' + filename, 'long');
66+
Lib.notifier(_(gd, 'Snapshot succeeded') + ' - ' + filename, 'long');
6567
})
6668
.catch(function() {
67-
Lib.notifier('Sorry there was a problem downloading your snapshot!', 'long');
69+
Lib.notifier(_(gd, 'Sorry there was a problem downloading your snapshot!'), 'long');
6870
});
6971
}
7072
};
7173

7274
modeBarButtons.sendDataToCloud = {
7375
name: 'sendDataToCloud',
74-
title: 'Edit in Chart Studio',
76+
title: function(gd) { return _(gd, 'Edit in Chart Studio'); },
7577
icon: Icons.disk,
7678
click: function(gd) {
7779
Plots.sendDataToCloud(gd);
@@ -80,7 +82,7 @@ modeBarButtons.sendDataToCloud = {
8082

8183
modeBarButtons.zoom2d = {
8284
name: 'zoom2d',
83-
title: 'Zoom',
85+
title: function(gd) { return _(gd, 'Zoom'); },
8486
attr: 'dragmode',
8587
val: 'zoom',
8688
icon: Icons.zoombox,
@@ -89,7 +91,7 @@ modeBarButtons.zoom2d = {
8991

9092
modeBarButtons.pan2d = {
9193
name: 'pan2d',
92-
title: 'Pan',
94+
title: function(gd) { return _(gd, 'Pan'); },
9395
attr: 'dragmode',
9496
val: 'pan',
9597
icon: Icons.pan,
@@ -98,7 +100,7 @@ modeBarButtons.pan2d = {
98100

99101
modeBarButtons.select2d = {
100102
name: 'select2d',
101-
title: 'Box Select',
103+
title: function(gd) { return _(gd, 'Box Select'); },
102104
attr: 'dragmode',
103105
val: 'select',
104106
icon: Icons.selectbox,
@@ -107,7 +109,7 @@ modeBarButtons.select2d = {
107109

108110
modeBarButtons.lasso2d = {
109111
name: 'lasso2d',
110-
title: 'Lasso Select',
112+
title: function(gd) { return _(gd, 'Lasso Select'); },
111113
attr: 'dragmode',
112114
val: 'lasso',
113115
icon: Icons.lasso,
@@ -116,7 +118,7 @@ modeBarButtons.lasso2d = {
116118

117119
modeBarButtons.zoomIn2d = {
118120
name: 'zoomIn2d',
119-
title: 'Zoom in',
121+
title: function(gd) { return _(gd, 'Zoom in'); },
120122
attr: 'zoom',
121123
val: 'in',
122124
icon: Icons.zoom_plus,
@@ -125,7 +127,7 @@ modeBarButtons.zoomIn2d = {
125127

126128
modeBarButtons.zoomOut2d = {
127129
name: 'zoomOut2d',
128-
title: 'Zoom out',
130+
title: function(gd) { return _(gd, 'Zoom out'); },
129131
attr: 'zoom',
130132
val: 'out',
131133
icon: Icons.zoom_minus,
@@ -134,7 +136,7 @@ modeBarButtons.zoomOut2d = {
134136

135137
modeBarButtons.autoScale2d = {
136138
name: 'autoScale2d',
137-
title: 'Autoscale',
139+
title: function(gd) { return _(gd, 'Autoscale'); },
138140
attr: 'zoom',
139141
val: 'auto',
140142
icon: Icons.autoscale,
@@ -143,7 +145,7 @@ modeBarButtons.autoScale2d = {
143145

144146
modeBarButtons.resetScale2d = {
145147
name: 'resetScale2d',
146-
title: 'Reset axes',
148+
title: function(gd) { return _(gd, 'Reset axes'); },
147149
attr: 'zoom',
148150
val: 'reset',
149151
icon: Icons.home,
@@ -152,7 +154,7 @@ modeBarButtons.resetScale2d = {
152154

153155
modeBarButtons.hoverClosestCartesian = {
154156
name: 'hoverClosestCartesian',
155-
title: 'Show closest data on hover',
157+
title: function(gd) { return _(gd, 'Show closest data on hover'); },
156158
attr: 'hovermode',
157159
val: 'closest',
158160
icon: Icons.tooltip_basic,
@@ -162,7 +164,7 @@ modeBarButtons.hoverClosestCartesian = {
162164

163165
modeBarButtons.hoverCompareCartesian = {
164166
name: 'hoverCompareCartesian',
165-
title: 'Compare data on hover',
167+
title: function(gd) { return _(gd, 'Compare data on hover'); },
166168
attr: 'hovermode',
167169
val: function(gd) {
168170
return gd._fullLayout._isHoriz ? 'y' : 'x';
@@ -256,7 +258,7 @@ function handleCartesian(gd, ev) {
256258

257259
modeBarButtons.zoom3d = {
258260
name: 'zoom3d',
259-
title: 'Zoom',
261+
title: function(gd) { return _(gd, 'Zoom'); },
260262
attr: 'scene.dragmode',
261263
val: 'zoom',
262264
icon: Icons.zoombox,
@@ -265,7 +267,7 @@ modeBarButtons.zoom3d = {
265267

266268
modeBarButtons.pan3d = {
267269
name: 'pan3d',
268-
title: 'Pan',
270+
title: function(gd) { return _(gd, 'Pan'); },
269271
attr: 'scene.dragmode',
270272
val: 'pan',
271273
icon: Icons.pan,
@@ -274,7 +276,7 @@ modeBarButtons.pan3d = {
274276

275277
modeBarButtons.orbitRotation = {
276278
name: 'orbitRotation',
277-
title: 'orbital rotation',
279+
title: function(gd) { return _(gd, 'Orbital rotation'); },
278280
attr: 'scene.dragmode',
279281
val: 'orbit',
280282
icon: Icons['3d_rotate'],
@@ -283,7 +285,7 @@ modeBarButtons.orbitRotation = {
283285

284286
modeBarButtons.tableRotation = {
285287
name: 'tableRotation',
286-
title: 'turntable rotation',
288+
title: function(gd) { return _(gd, 'Turntable rotation'); },
287289
attr: 'scene.dragmode',
288290
val: 'turntable',
289291
icon: Icons['z-axis'],
@@ -309,15 +311,15 @@ function handleDrag3d(gd, ev) {
309311

310312
modeBarButtons.resetCameraDefault3d = {
311313
name: 'resetCameraDefault3d',
312-
title: 'Reset camera to default',
314+
title: function(gd) { return _(gd, 'Reset camera to default'); },
313315
attr: 'resetDefault',
314316
icon: Icons.home,
315317
click: handleCamera3d
316318
};
317319

318320
modeBarButtons.resetCameraLastSave3d = {
319321
name: 'resetCameraLastSave3d',
320-
title: 'Reset camera to last save',
322+
title: function(gd) { return _(gd, 'Reset camera to last save'); },
321323
attr: 'resetLastSave',
322324
icon: Icons.movie,
323325
click: handleCamera3d
@@ -348,7 +350,7 @@ function handleCamera3d(gd, ev) {
348350

349351
modeBarButtons.hoverClosest3d = {
350352
name: 'hoverClosest3d',
351-
title: 'Toggle show closest data on hover',
353+
title: function(gd) { return _(gd, 'Toggle show closest data on hover'); },
352354
attr: 'hovermode',
353355
val: null,
354356
toggle: true,
@@ -409,7 +411,7 @@ function handleHover3d(gd, ev) {
409411

410412
modeBarButtons.zoomInGeo = {
411413
name: 'zoomInGeo',
412-
title: 'Zoom in',
414+
title: function(gd) { return _(gd, 'Zoom in'); },
413415
attr: 'zoom',
414416
val: 'in',
415417
icon: Icons.zoom_plus,
@@ -418,7 +420,7 @@ modeBarButtons.zoomInGeo = {
418420

419421
modeBarButtons.zoomOutGeo = {
420422
name: 'zoomOutGeo',
421-
title: 'Zoom out',
423+
title: function(gd) { return _(gd, 'Zoom out'); },
422424
attr: 'zoom',
423425
val: 'out',
424426
icon: Icons.zoom_minus,
@@ -427,7 +429,7 @@ modeBarButtons.zoomOutGeo = {
427429

428430
modeBarButtons.resetGeo = {
429431
name: 'resetGeo',
430-
title: 'Reset',
432+
title: function(gd) { return _(gd, 'Reset'); },
431433
attr: 'reset',
432434
val: null,
433435
icon: Icons.autoscale,
@@ -436,7 +438,7 @@ modeBarButtons.resetGeo = {
436438

437439
modeBarButtons.hoverClosestGeo = {
438440
name: 'hoverClosestGeo',
439-
title: 'Toggle show closest data on hover',
441+
title: function(gd) { return _(gd, 'Toggle show closest data on hover'); },
440442
attr: 'hovermode',
441443
val: null,
442444
toggle: true,
@@ -469,7 +471,7 @@ function handleGeo(gd, ev) {
469471

470472
modeBarButtons.hoverClosestGl2d = {
471473
name: 'hoverClosestGl2d',
472-
title: 'Toggle show closest data on hover',
474+
title: function(gd) { return _(gd, 'Toggle show closest data on hover'); },
473475
attr: 'hovermode',
474476
val: null,
475477
toggle: true,
@@ -480,7 +482,7 @@ modeBarButtons.hoverClosestGl2d = {
480482

481483
modeBarButtons.hoverClosestPie = {
482484
name: 'hoverClosestPie',
483-
title: 'Toggle show closest data on hover',
485+
title: function(gd) { return _(gd, 'Toggle show closest data on hover'); },
484486
attr: 'hovermode',
485487
val: 'closest',
486488
icon: Icons.tooltip_basic,
@@ -506,7 +508,7 @@ function toggleHover(gd) {
506508

507509
modeBarButtons.toggleHover = {
508510
name: 'toggleHover',
509-
title: 'Toggle show closest data on hover',
511+
title: function(gd) { return _(gd, 'Toggle show closest data on hover'); },
510512
attr: 'hovermode',
511513
val: null,
512514
toggle: true,
@@ -524,7 +526,7 @@ modeBarButtons.toggleHover = {
524526

525527
modeBarButtons.resetViews = {
526528
name: 'resetViews',
527-
title: 'Reset views',
529+
title: function(gd) { return _(gd, 'Reset views'); },
528530
icon: Icons.home,
529531
click: function(gd, ev) {
530532
var button = ev.currentTarget;
@@ -543,7 +545,7 @@ modeBarButtons.resetViews = {
543545

544546
modeBarButtons.toggleSpikelines = {
545547
name: 'toggleSpikelines',
546-
title: 'Toggle Spike Lines',
548+
title: function(gd) { return _(gd, 'Toggle Spike Lines'); },
547549
icon: Icons.spikeline,
548550
attr: '_cartesianSpikesEnabled',
549551
val: 'on',
@@ -578,7 +580,7 @@ function setSpikelineVisibility(gd) {
578580

579581
modeBarButtons.resetViewMapbox = {
580582
name: 'resetViewMapbox',
581-
title: 'Reset view',
583+
title: function(gd) { return _(gd, 'Reset view'); },
582584
attr: 'reset',
583585
icon: Icons.home,
584586
click: function(gd) {

src/components/modebar/modebar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ proto.createButton = function(config) {
123123

124124
var title = config.title;
125125
if(title === undefined) title = config.name;
126+
// for localization: allow title to be a callable that takes gd as arg
127+
else if(typeof title === 'function') title = title(this.graphInfo);
128+
126129
if(title || title === 0) button.setAttribute('data-title', title);
127130

128131
if(config.attr !== undefined) button.setAttribute('data-attr', config.attr);
@@ -250,7 +253,7 @@ proto.getLogo = function() {
250253

251254
a.href = 'https://plot.ly/';
252255
a.target = '_blank';
253-
a.setAttribute('data-title', 'Produced with Plotly');
256+
a.setAttribute('data-title', Lib._(this.graphInfo, 'Produced with Plotly'));
254257
a.className = 'modebar-btn plotlyjsicon modebar-btn--logo';
255258

256259
a.appendChild(this.createIcon(Icons.plotlylogo));

src/components/rangeslider/draw.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
372372
width: opts._width,
373373
height: opts._height,
374374
margin: { t: 0, b: 0, l: 0, r: 0 }
375-
}
375+
},
376+
_context: gd._context
376377
};
377378

378379
mockFigure.layout[oppAxisName] = {

0 commit comments

Comments
 (0)