Skip to content

Commit 4a60cc2

Browse files
authored
Merge pull request #225 from plotly/arrows-translation
make and write an arrows translation we can use for testing
2 parents 8688032 + a57a339 commit 4a60cc2

File tree

4 files changed

+264
-0
lines changed

4 files changed

+264
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"lint": "prettier --write \"src/**/*.js\"",
1717
"make:combined-translation-keys": "babel-node scripts/findTranslationKeys.js && babel-node scripts/combineTranslationKeys.js",
1818
"make:translation-keys": "babel-node scripts/findTranslationKeys.js",
19+
"make:arrows": "babel-node scripts/makeArrows.js",
1920
"make:lib": "mkdirp lib && npm run make:lib:js && npm run make:lib:css",
2021
"make:lib:js": "mkdirp lib && babel src --out-dir lib --ignore=__tests__/* --source-maps",
2122
"make:lib:css": "mkdirp lib && babel-node scripts/styles.js && SASS_ENV=ie babel-node scripts/styles.js && babel-node scripts/postcss.js && SASS_ENV=ie babel-node scripts/postcss.js",

scripts/makeArrows.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import path from 'path';
2+
import fs from 'fs';
3+
4+
const pathToCombinedTranslationKeys = path.join(
5+
__dirname,
6+
'./translationKeys/combined-translation-keys.txt'
7+
);
8+
9+
const pathToArrowsOut = path.join(__dirname, '../src/locales/xx.js');
10+
11+
const wordRE = /^[A-Za-z]+$/;
12+
13+
function makeArrows() {
14+
const lines = fs
15+
.readFileSync(pathToCombinedTranslationKeys, 'utf-8')
16+
.split(/\r?\n/);
17+
const entries = lines
18+
.map(line => {
19+
const key = line.split(/\/\//)[0].trim();
20+
const quoteChar = key.indexOf("'") === -1 ? "'" : '"';
21+
22+
if (key.indexOf('"') !== -1) {
23+
throw new Error('double quotes are not supported, key: ' + key);
24+
}
25+
26+
const maybeQuoteKey = wordRE.test(key)
27+
? key
28+
: quoteChar + key + quoteChar;
29+
const arrowStr = arrowPad(getArrowLen(key));
30+
31+
const quotedVal = quoteChar + arrowStr + key + arrowStr + quoteChar + ',';
32+
const singleLine = ' ' + maybeQuoteKey + ': ' + quotedVal;
33+
34+
if (singleLine.length <= 80) return singleLine;
35+
36+
return ' ' + maybeQuoteKey + ':\n ' + quotedVal;
37+
})
38+
.join('\n');
39+
40+
const head = 'export default {';
41+
const tail = '};\n';
42+
43+
fs.writeFile(pathToArrowsOut, [head, entries, tail].join('\n'));
44+
console.log('arrows mock translation written to: ' + pathToArrowsOut);
45+
}
46+
47+
// inferred from the arrow file Greg provided
48+
function getArrowLen(key) {
49+
return Math.max(1, Math.round(key.length / 5.7));
50+
}
51+
52+
function arrowPad(n) {
53+
let out = '';
54+
for (let i = 0; i < n; i++) {
55+
out += '⇚';
56+
}
57+
return out;
58+
}
59+
60+
makeArrows();
61+
62+
process.on('exit', function(code) {
63+
if (code === 1) {
64+
throw new Error('makeArrows failed.');
65+
}
66+
});

src/locales/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import en from './en';
2+
import xx from './xx';
23

34
export default {
45
en: en,
6+
xx: xx,
57
};

src/locales/xx.js

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
export default {
2+
'Anchor Point': '⇚⇚Anchor Point⇚⇚',
3+
Angle: '⇚Angle⇚',
4+
Annotation: '⇚⇚Annotation⇚⇚',
5+
Arrow: '⇚Arrow⇚',
6+
Arrowhead: '⇚⇚Arrowhead⇚⇚',
7+
Auto: '⇚Auto⇚',
8+
Autoscale: '⇚⇚Autoscale⇚⇚',
9+
Axes: '⇚Axes⇚',
10+
'Background Color': '⇚⇚⇚Background Color⇚⇚⇚',
11+
'Bar Padding': '⇚⇚Bar Padding⇚⇚',
12+
'Bar Width': '⇚⇚Bar Width⇚⇚',
13+
Bars: '⇚Bars⇚',
14+
Blank: '⇚Blank⇚',
15+
'Border Color': '⇚⇚Border Color⇚⇚',
16+
'Border Width': '⇚⇚Border Width⇚⇚',
17+
Bottom: '⇚Bottom⇚',
18+
'Box Padding': '⇚⇚Box Padding⇚⇚',
19+
'Box Select': '⇚⇚Box Select⇚⇚',
20+
'Box Width': '⇚⇚Box Width⇚⇚',
21+
Canvas: '⇚Canvas⇚',
22+
Center: '⇚Center⇚',
23+
'Click to enter Colorscale title':
24+
'⇚⇚⇚⇚⇚Click to enter Colorscale title⇚⇚⇚⇚⇚',
25+
'Click to enter Component A title':
26+
'⇚⇚⇚⇚⇚⇚Click to enter Component A title⇚⇚⇚⇚⇚⇚',
27+
'Click to enter Component B title':
28+
'⇚⇚⇚⇚⇚⇚Click to enter Component B title⇚⇚⇚⇚⇚⇚',
29+
'Click to enter Component C title':
30+
'⇚⇚⇚⇚⇚⇚Click to enter Component C title⇚⇚⇚⇚⇚⇚',
31+
'Click to enter Plot title': '⇚⇚⇚⇚Click to enter Plot title⇚⇚⇚⇚',
32+
'Click to enter X axis title': '⇚⇚⇚⇚⇚Click to enter X axis title⇚⇚⇚⇚⇚',
33+
'Click to enter Y axis title': '⇚⇚⇚⇚⇚Click to enter Y axis title⇚⇚⇚⇚⇚',
34+
Color: '⇚Color⇚',
35+
"Common Case: An 'All' tab might display this message because the X and Y tabs contain different settings.":
36+
"⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Common Case: An 'All' tab might display this message because the X and Y tabs contain different settings.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚",
37+
'Compare data on hover': '⇚⇚⇚⇚Compare data on hover⇚⇚⇚⇚',
38+
Connect: '⇚Connect⇚',
39+
'Connect Gaps': '⇚⇚Connect Gaps⇚⇚',
40+
Continue: '⇚Continue⇚',
41+
'Continuing will convert your LaTeX expression into raw text.':
42+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Continuing will convert your LaTeX expression into raw text.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚',
43+
'Continuing will convert your note to LaTeX-style text.':
44+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚Continuing will convert your note to LaTeX-style text.⇚⇚⇚⇚⇚⇚⇚⇚⇚',
45+
'Continuing will remove your expression.':
46+
'⇚⇚⇚⇚⇚⇚⇚Continuing will remove your expression.⇚⇚⇚⇚⇚⇚⇚',
47+
Custom: '⇚Custom⇚',
48+
'Custom Color': '⇚⇚Custom Color⇚⇚',
49+
'Default Colors': '⇚⇚Default Colors⇚⇚',
50+
Display: '⇚Display⇚',
51+
'Double-click on legend to isolate one trace':
52+
'⇚⇚⇚⇚⇚⇚⇚⇚Double-click on legend to isolate one trace⇚⇚⇚⇚⇚⇚⇚⇚',
53+
'Double-click to zoom back out': '⇚⇚⇚⇚⇚Double-click to zoom back out⇚⇚⇚⇚⇚',
54+
'Download plot as a png': '⇚⇚⇚⇚Download plot as a png⇚⇚⇚⇚',
55+
'Edit in Chart Studio': '⇚⇚⇚⇚Edit in Chart Studio⇚⇚⇚⇚',
56+
'Edit in HTML': '⇚⇚Edit in HTML⇚⇚',
57+
'Edit in Rich Text': '⇚⇚⇚Edit in Rich Text⇚⇚⇚',
58+
'Enter Link URL': '⇚⇚Enter Link URL⇚⇚',
59+
'Filled Area': '⇚⇚Filled Area⇚⇚',
60+
'Fixed Height': '⇚⇚Fixed Height⇚⇚',
61+
'Fixed Width': '⇚⇚Fixed Width⇚⇚',
62+
'Font Color': '⇚⇚Font Color⇚⇚',
63+
'Font Size': '⇚⇚Font Size⇚⇚',
64+
'Global Font': '⇚⇚Global Font⇚⇚',
65+
'Go back': '⇚Go back⇚',
66+
"Go to the 'Create' tab to define traces.":
67+
"⇚⇚⇚⇚⇚⇚⇚Go to the 'Create' tab to define traces.⇚⇚⇚⇚⇚⇚⇚",
68+
'Heads up!': '⇚⇚Heads up!⇚⇚',
69+
Hide: '⇚Hide⇚',
70+
Horizontal: '⇚⇚Horizontal⇚⇚',
71+
'Horizontal Positioning': '⇚⇚⇚⇚Horizontal Positioning⇚⇚⇚⇚',
72+
'IE only supports svg. Changing format to svg.':
73+
'⇚⇚⇚⇚⇚⇚⇚⇚IE only supports svg. Changing format to svg.⇚⇚⇚⇚⇚⇚⇚⇚',
74+
LaTeX: '⇚LaTeX⇚',
75+
"LaTeX is a math typesetting language that doesn't work with rich text.":
76+
"⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚LaTeX is a math typesetting language that doesn't work with rich text.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚",
77+
'Lasso Select': '⇚⇚Lasso Select⇚⇚',
78+
Layout: '⇚Layout⇚',
79+
Left: '⇚Left⇚',
80+
Legend: '⇚Legend⇚',
81+
'Legend Box': '⇚⇚Legend Box⇚⇚',
82+
'Line Color': '⇚⇚Line Color⇚⇚',
83+
'Line Width': '⇚⇚Line Width⇚⇚',
84+
Linear: '⇚Linear⇚',
85+
Lines: '⇚Lines⇚',
86+
"Looks like there aren't any traces defined yet.":
87+
"⇚⇚⇚⇚⇚⇚⇚⇚Looks like there aren't any traces defined yet.⇚⇚⇚⇚⇚⇚⇚⇚",
88+
'Margin Color': '⇚⇚Margin Color⇚⇚',
89+
'Margins and Padding': '⇚⇚⇚Margins and Padding⇚⇚⇚',
90+
Max: '⇚Max⇚',
91+
Middle: '⇚Middle⇚',
92+
Min: '⇚Min⇚',
93+
'Multiple Values': '⇚⇚⇚Multiple Values⇚⇚⇚',
94+
Normal: '⇚Normal⇚',
95+
'Note Text': '⇚⇚Note Text⇚⇚',
96+
Notes: '⇚Notes⇚',
97+
Opacity: '⇚Opacity⇚',
98+
'Orbital rotation': '⇚⇚⇚Orbital rotation⇚⇚⇚',
99+
Orientation: '⇚⇚Orientation⇚⇚',
100+
Padding: '⇚Padding⇚',
101+
Pan: '⇚Pan⇚',
102+
'Plot Background': '⇚⇚⇚Plot Background⇚⇚⇚',
103+
Points: '⇚Points⇚',
104+
Position: '⇚Position⇚',
105+
Positioning: '⇚⇚Positioning⇚⇚',
106+
'Produced with Plotly': '⇚⇚⇚⇚Produced with Plotly⇚⇚⇚⇚',
107+
Range: '⇚Range⇚',
108+
'Relative To': '⇚⇚Relative To⇚⇚',
109+
Reset: '⇚Reset⇚',
110+
'Reset axes': '⇚⇚Reset axes⇚⇚',
111+
'Reset camera to default': '⇚⇚⇚⇚Reset camera to default⇚⇚⇚⇚',
112+
'Reset camera to last save': '⇚⇚⇚⇚Reset camera to last save⇚⇚⇚⇚',
113+
'Reset view': '⇚⇚Reset view⇚⇚',
114+
'Reset views': '⇚⇚Reset views⇚⇚',
115+
'Return to the Graph > Create menu above to add data.':
116+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚Return to the Graph > Create menu above to add data.⇚⇚⇚⇚⇚⇚⇚⇚⇚',
117+
Reversed: '⇚Reversed⇚',
118+
'Rich Text': '⇚⇚Rich Text⇚⇚',
119+
'Rich text is incompatible with LaTeX.':
120+
'⇚⇚⇚⇚⇚⇚Rich text is incompatible with LaTeX.⇚⇚⇚⇚⇚⇚',
121+
Right: '⇚Right⇚',
122+
Scale: '⇚Scale⇚',
123+
Selection: '⇚⇚Selection⇚⇚',
124+
Shape: '⇚Shape⇚',
125+
Show: '⇚Show⇚',
126+
'Show closest data on hover': '⇚⇚⇚⇚⇚Show closest data on hover⇚⇚⇚⇚⇚',
127+
Size: '⇚Size⇚',
128+
'Size and Spacing': '⇚⇚⇚Size and Spacing⇚⇚⇚',
129+
'Snapshot succeeded': '⇚⇚⇚Snapshot succeeded⇚⇚⇚',
130+
'Sorry, there was a problem downloading your snapshot!':
131+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚Sorry, there was a problem downloading your snapshot!⇚⇚⇚⇚⇚⇚⇚⇚⇚',
132+
Symbol: '⇚Symbol⇚',
133+
'Taking snapshot - this may take a few seconds':
134+
'⇚⇚⇚⇚⇚⇚⇚⇚Taking snapshot - this may take a few seconds⇚⇚⇚⇚⇚⇚⇚⇚',
135+
Text: '⇚Text⇚',
136+
'Text Attributes': '⇚⇚⇚Text Attributes⇚⇚⇚',
137+
"The anchor point determines which side of the annotation's positioning coordinates refer to.":
138+
"⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚The anchor point determines which side of the annotation's positioning coordinates refer to.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚",
139+
'The positioning inputs are relative to the anchor points on the text box.':
140+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚The positioning inputs are relative to the anchor points on the text box.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚',
141+
'This input has multiple values associated with it. Changing this setting will override these custom inputs.':
142+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚This input has multiple values associated with it. Changing this setting will override these custom inputs.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚',
143+
'This trace does not yet have any data.':
144+
'⇚⇚⇚⇚⇚⇚⇚This trace does not yet have any data.⇚⇚⇚⇚⇚⇚⇚',
145+
'Tick Labels': '⇚⇚Tick Labels⇚⇚',
146+
'Tick Markers': '⇚⇚Tick Markers⇚⇚',
147+
Title: '⇚Title⇚',
148+
'Title and Fonts': '⇚⇚⇚Title and Fonts⇚⇚⇚',
149+
Titles: '⇚Titles⇚',
150+
'Toggle Spike Lines': '⇚⇚⇚Toggle Spike Lines⇚⇚⇚',
151+
'Toggle show closest data on hover':
152+
'⇚⇚⇚⇚⇚⇚Toggle show closest data on hover⇚⇚⇚⇚⇚⇚',
153+
Top: '⇚Top⇚',
154+
Trace: '⇚Trace⇚',
155+
'Trace Order': '⇚⇚Trace Order⇚⇚',
156+
'Trace opacity is not supported for a scatter trace with fill or for a scatter trace that gets filled by another scatter trace.':
157+
'⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Trace opacity is not supported for a scatter trace with fill or for a scatter trace that gets filled by another scatter trace.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚',
158+
'Turntable rotation': '⇚⇚⇚Turntable rotation⇚⇚⇚',
159+
Type: '⇚Type⇚',
160+
Typeface: '⇚Typeface⇚',
161+
URL: '⇚URL⇚',
162+
Vertical: '⇚Vertical⇚',
163+
'Vertical Positioning': '⇚⇚⇚⇚Vertical Positioning⇚⇚⇚⇚',
164+
Width: '⇚Width⇚',
165+
'X Position': '⇚⇚X Position⇚⇚',
166+
'X Vector': '⇚X Vector⇚',
167+
'Y Position': '⇚⇚Y Position⇚⇚',
168+
'Y Vector': '⇚Y Vector⇚',
169+
Zoom: '⇚Zoom⇚',
170+
'Zoom Interactivity': '⇚⇚⇚Zoom Interactivity⇚⇚⇚',
171+
'Zoom in': '⇚Zoom in⇚',
172+
'Zoom out': '⇚Zoom out⇚',
173+
'close:': '⇚close:⇚',
174+
'high:': '⇚high:⇚',
175+
'incoming flow count:': '⇚⇚⇚⇚incoming flow count:⇚⇚⇚⇚',
176+
'kde:': '⇚kde:⇚',
177+
'lat:': '⇚lat:⇚',
178+
log: '⇚log⇚',
179+
'lon:': '⇚lon:⇚',
180+
'low:': '⇚low:⇚',
181+
'lower fence:': '⇚⇚lower fence:⇚⇚',
182+
'max:': '⇚max:⇚',
183+
'mean ± σ:': '⇚⇚mean ± σ:⇚⇚',
184+
'mean:': '⇚mean:⇚',
185+
'median:': '⇚median:⇚',
186+
'min:': '⇚min:⇚',
187+
'open:': '⇚open:⇚',
188+
'outgoing flow count:': '⇚⇚⇚⇚outgoing flow count:⇚⇚⇚⇚',
189+
'q1:': '⇚q1:⇚',
190+
'q3:': '⇚q3:⇚',
191+
'source:': '⇚source:⇚',
192+
'target:': '⇚target:⇚',
193+
trace: '⇚trace⇚',
194+
'upper fence:': '⇚⇚upper fence:⇚⇚',
195+
};

0 commit comments

Comments
 (0)