Skip to content

Commit 97c0898

Browse files
committed
include file & line number with translation keys
1 parent 5d6f267 commit 97c0898

File tree

2 files changed

+72
-63
lines changed

2 files changed

+72
-63
lines changed

dist/translation-keys.txt

+56-60
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,56 @@
1-
Autoscale
2-
Box Select
3-
Click to enter Colorscale title
4-
Click to enter Component A title
5-
Click to enter Component B title
6-
Click to enter Component C title
7-
Click to enter Plot title
8-
Click to enter X axis title
9-
Click to enter Y axis title
10-
Close:
11-
Compare data on hover
12-
Double click on legend to isolate individual trace
13-
Double-click to<br>zoom back out
14-
Download plot as a png
15-
Edit in Chart Studio
16-
High:
17-
IE only supports svg. Changing format to svg.
18-
Incoming flow count:
19-
Lasso Select
20-
Low:
21-
Open:
22-
Orbital rotation
23-
Outgoing flow count:
24-
Pan
25-
Produced with Plotly
26-
Reset
27-
Reset axes
28-
Reset camera to default
29-
Reset camera to last save
30-
Reset view
31-
Reset views
32-
Show closest data on hover
33-
Snapshot succeeded
34-
Sorry there was a problem downloading your snapshot!
35-
Source:
36-
Taking snapshot - this may take a few seconds
37-
Target:
38-
Toggle Spike Lines
39-
Toggle show closest data on hover
40-
Turntable rotation
41-
Zoom
42-
Zoom in
43-
Zoom out
44-
cannot use zsmooth: "fast"
45-
kde:
46-
lat:
47-
log axis found
48-
lon:
49-
lower fence:
50-
max:
51-
mean ± σ:
52-
mean:
53-
median:
54-
min:
55-
q1:
56-
q3:
57-
trace
58-
upper fence:
59-
x scale is not linear
60-
y scale is not linear
1+
Autoscale // components/modebar/buttons.js:139
2+
Box Select // components/modebar/buttons.js:103
3+
Click to enter Colorscale title // plots/plots.js:437
4+
Click to enter Component A title // plots/ternary/ternary.js:386
5+
Click to enter Component B title // plots/ternary/ternary.js:400
6+
Click to enter Component C title // plots/ternary/ternary.js:411
7+
Click to enter Plot title // plot_api/plot_api.js:579
8+
Click to enter X axis title // plots/plots.js:435
9+
Click to enter Y axis title // plots/plots.js:436
10+
Close: // traces/ohlc/transform.js:139
11+
Compare data on hover // components/modebar/buttons.js:167
12+
Double click on legend to isolate individual trace // components/legend/handle_click.js:90
13+
Double-click to zoom back out // plots/cartesian/dragbox.js:299
14+
Download plot as a png // components/modebar/buttons.js:52
15+
Edit in Chart Studio // components/modebar/buttons.js:76
16+
High: // traces/ohlc/transform.js:137
17+
IE only supports svg. Changing format to svg. // components/modebar/buttons.js:60
18+
Incoming flow count: // traces/sankey/plot.js:142
19+
Lasso Select // components/modebar/buttons.js:112
20+
Low: // traces/ohlc/transform.js:138
21+
Open: // traces/ohlc/transform.js:136
22+
Orbital rotation // components/modebar/buttons.js:279
23+
Outgoing flow count: // traces/sankey/plot.js:143
24+
Pan // components/modebar/buttons.js:94
25+
Produced with Plotly // components/modebar/modebar.js:256
26+
Reset // components/modebar/buttons.js:432
27+
Reset axes // components/modebar/buttons.js:148
28+
Reset camera to default // components/modebar/buttons.js:314
29+
Reset camera to last save // components/modebar/buttons.js:322
30+
Reset view // components/modebar/buttons.js:583
31+
Reset views // components/modebar/buttons.js:529
32+
Show closest data on hover // components/modebar/buttons.js:157
33+
Snapshot succeeded // components/modebar/buttons.js:66
34+
Sorry there was a problem downloading your snapshot! // components/modebar/buttons.js:69
35+
Source: // traces/sankey/plot.js:140
36+
Taking snapshot - this may take a few seconds // components/modebar/buttons.js:57
37+
Target: // traces/sankey/plot.js:141
38+
Toggle Spike Lines // components/modebar/buttons.js:548
39+
Toggle show closest data on hover // components/modebar/buttons.js:353
40+
Turntable rotation // components/modebar/buttons.js:288
41+
Zoom // components/modebar/buttons.js:85
42+
Zoom in // components/modebar/buttons.js:121
43+
Zoom out // components/modebar/buttons.js:130
44+
kde: // traces/violin/calc.js:73
45+
lat: // traces/scattergeo/calc.js:48
46+
lon: // traces/scattergeo/calc.js:49
47+
lower fence: // traces/box/calc.js:134
48+
max: // traces/box/calc.js:132
49+
mean ± σ: // traces/box/calc.js:133
50+
mean: // traces/box/calc.js:133
51+
median: // traces/box/calc.js:128
52+
min: // traces/box/calc.js:129
53+
q1: // traces/box/calc.js:130
54+
q3: // traces/box/calc.js:131
55+
trace // plots/plots.js:439
56+
upper fence: // traces/box/calc.js:135

tasks/find_locale_strings.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ function findLocaleStrings() {
2626

2727
var dict = {};
2828
var hasTranslation = false;
29+
var maxLen = 0;
2930

3031
files.forEach(function(file) {
3132
var code = fs.readFileSync(file, 'utf-8');
33+
var filePartialPath = file.substr(constants.pathToSrc.length);
3234

3335
falafel(code, {locations: true}, function(node) {
3436
// parse through code string looking for translated strings
@@ -44,8 +46,11 @@ function findLocaleStrings() {
4446
if(strNode.type !== 'Literal') {
4547
logError(file, node, 'Translated string must be a literal');
4648
}
47-
dict[strNode.value] = 1;
48-
hasTranslation = true;
49+
if(!dict[strNode.value]) {
50+
dict[strNode.value] = filePartialPath + ':' + node.loc.start.line;
51+
maxLen = Math.max(maxLen, strNode.value.length);
52+
hasTranslation = true;
53+
}
4954
}
5055

5156
// make sure localize is the only thing we assign to a variable `_`
@@ -65,7 +70,9 @@ function findLocaleStrings() {
6570
}
6671

6772
if(!EXIT_CODE) {
68-
var strings = Object.keys(dict).sort().join('\n');
73+
var strings = Object.keys(dict).sort().map(function(k) {
74+
return k + spaces(maxLen - k.length) + ' // ' + dict[k];
75+
}).join('\n');
6976
common.writeFile(constants.pathToTranslationKeys, strings);
7077
console.log('ok find_locale_strings');
7178
}
@@ -78,6 +85,12 @@ function logError(file, node, msg) {
7885
EXIT_CODE = 1;
7986
}
8087

88+
function spaces(len) {
89+
var out = '';
90+
for(var i = 0; i < len; i++) out += ' ';
91+
return out;
92+
}
93+
8194
process.on('exit', function() {
8295
if(EXIT_CODE) {
8396
throw new Error('find_locale_strings failed.');

0 commit comments

Comments
 (0)