diff --git a/package.json b/package.json index 3716d5453..2472f5adc 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "lint": "prettier --write \"src/**/*.js\"", "make:combined-translation-keys": "babel-node scripts/findTranslationKeys.js && babel-node scripts/combineTranslationKeys.js", "make:translation-keys": "babel-node scripts/findTranslationKeys.js", + "make:arrows": "babel-node scripts/makeArrows.js", "make:lib": "mkdirp lib && npm run make:lib:js && npm run make:lib:css", "make:lib:js": "mkdirp lib && babel src --out-dir lib --ignore=__tests__/* --source-maps", "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", diff --git a/scripts/makeArrows.js b/scripts/makeArrows.js new file mode 100644 index 000000000..aad64fcfb --- /dev/null +++ b/scripts/makeArrows.js @@ -0,0 +1,66 @@ +import path from 'path'; +import fs from 'fs'; + +const pathToCombinedTranslationKeys = path.join( + __dirname, + './translationKeys/combined-translation-keys.txt' +); + +const pathToArrowsOut = path.join(__dirname, '../src/locales/xx.js'); + +const wordRE = /^[A-Za-z]+$/; + +function makeArrows() { + const lines = fs + .readFileSync(pathToCombinedTranslationKeys, 'utf-8') + .split(/\r?\n/); + const entries = lines + .map(line => { + const key = line.split(/\/\//)[0].trim(); + const quoteChar = key.indexOf("'") === -1 ? "'" : '"'; + + if (key.indexOf('"') !== -1) { + throw new Error('double quotes are not supported, key: ' + key); + } + + const maybeQuoteKey = wordRE.test(key) + ? key + : quoteChar + key + quoteChar; + const arrowStr = arrowPad(getArrowLen(key)); + + const quotedVal = quoteChar + arrowStr + key + arrowStr + quoteChar + ','; + const singleLine = ' ' + maybeQuoteKey + ': ' + quotedVal; + + if (singleLine.length <= 80) return singleLine; + + return ' ' + maybeQuoteKey + ':\n ' + quotedVal; + }) + .join('\n'); + + const head = 'export default {'; + const tail = '};\n'; + + fs.writeFile(pathToArrowsOut, [head, entries, tail].join('\n')); + console.log('arrows mock translation written to: ' + pathToArrowsOut); +} + +// inferred from the arrow file Greg provided +function getArrowLen(key) { + return Math.max(1, Math.round(key.length / 5.7)); +} + +function arrowPad(n) { + let out = ''; + for (let i = 0; i < n; i++) { + out += '⇚'; + } + return out; +} + +makeArrows(); + +process.on('exit', function(code) { + if (code === 1) { + throw new Error('makeArrows failed.'); + } +}); diff --git a/src/locales/index.js b/src/locales/index.js index cea9e735a..acdfdf0e4 100644 --- a/src/locales/index.js +++ b/src/locales/index.js @@ -1,5 +1,7 @@ import en from './en'; +import xx from './xx'; export default { en: en, + xx: xx, }; diff --git a/src/locales/xx.js b/src/locales/xx.js new file mode 100644 index 000000000..7705abac0 --- /dev/null +++ b/src/locales/xx.js @@ -0,0 +1,195 @@ +export default { + 'Anchor Point': '⇚⇚Anchor Point⇚⇚', + Angle: '⇚Angle⇚', + Annotation: '⇚⇚Annotation⇚⇚', + Arrow: '⇚Arrow⇚', + Arrowhead: '⇚⇚Arrowhead⇚⇚', + Auto: '⇚Auto⇚', + Autoscale: '⇚⇚Autoscale⇚⇚', + Axes: '⇚Axes⇚', + 'Background Color': '⇚⇚⇚Background Color⇚⇚⇚', + 'Bar Padding': '⇚⇚Bar Padding⇚⇚', + 'Bar Width': '⇚⇚Bar Width⇚⇚', + Bars: '⇚Bars⇚', + Blank: '⇚Blank⇚', + 'Border Color': '⇚⇚Border Color⇚⇚', + 'Border Width': '⇚⇚Border Width⇚⇚', + Bottom: '⇚Bottom⇚', + 'Box Padding': '⇚⇚Box Padding⇚⇚', + 'Box Select': '⇚⇚Box Select⇚⇚', + 'Box Width': '⇚⇚Box Width⇚⇚', + Canvas: '⇚Canvas⇚', + Center: '⇚Center⇚', + 'Click to enter Colorscale title': + '⇚⇚⇚⇚⇚Click to enter Colorscale title⇚⇚⇚⇚⇚', + 'Click to enter Component A title': + '⇚⇚⇚⇚⇚⇚Click to enter Component A title⇚⇚⇚⇚⇚⇚', + 'Click to enter Component B title': + '⇚⇚⇚⇚⇚⇚Click to enter Component B title⇚⇚⇚⇚⇚⇚', + 'Click to enter Component C title': + '⇚⇚⇚⇚⇚⇚Click to enter Component C title⇚⇚⇚⇚⇚⇚', + 'Click to enter Plot title': '⇚⇚⇚⇚Click to enter Plot title⇚⇚⇚⇚', + 'Click to enter X axis title': '⇚⇚⇚⇚⇚Click to enter X axis title⇚⇚⇚⇚⇚', + 'Click to enter Y axis title': '⇚⇚⇚⇚⇚Click to enter Y axis title⇚⇚⇚⇚⇚', + Color: '⇚Color⇚', + "Common Case: An 'All' tab might display this message because the X and Y tabs contain different settings.": + "⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Common Case: An 'All' tab might display this message because the X and Y tabs contain different settings.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚", + 'Compare data on hover': '⇚⇚⇚⇚Compare data on hover⇚⇚⇚⇚', + Connect: '⇚Connect⇚', + 'Connect Gaps': '⇚⇚Connect Gaps⇚⇚', + Continue: '⇚Continue⇚', + 'Continuing will convert your LaTeX expression into raw text.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Continuing will convert your LaTeX expression into raw text.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚', + 'Continuing will convert your note to LaTeX-style text.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚Continuing will convert your note to LaTeX-style text.⇚⇚⇚⇚⇚⇚⇚⇚⇚', + 'Continuing will remove your expression.': + '⇚⇚⇚⇚⇚⇚⇚Continuing will remove your expression.⇚⇚⇚⇚⇚⇚⇚', + Custom: '⇚Custom⇚', + 'Custom Color': '⇚⇚Custom Color⇚⇚', + 'Default Colors': '⇚⇚Default Colors⇚⇚', + Display: '⇚Display⇚', + 'Double-click on legend to isolate one trace': + '⇚⇚⇚⇚⇚⇚⇚⇚Double-click on legend to isolate one trace⇚⇚⇚⇚⇚⇚⇚⇚', + 'Double-click to zoom back out': '⇚⇚⇚⇚⇚Double-click to zoom back out⇚⇚⇚⇚⇚', + 'Download plot as a png': '⇚⇚⇚⇚Download plot as a png⇚⇚⇚⇚', + 'Edit in Chart Studio': '⇚⇚⇚⇚Edit in Chart Studio⇚⇚⇚⇚', + 'Edit in HTML': '⇚⇚Edit in HTML⇚⇚', + 'Edit in Rich Text': '⇚⇚⇚Edit in Rich Text⇚⇚⇚', + 'Enter Link URL': '⇚⇚Enter Link URL⇚⇚', + 'Filled Area': '⇚⇚Filled Area⇚⇚', + 'Fixed Height': '⇚⇚Fixed Height⇚⇚', + 'Fixed Width': '⇚⇚Fixed Width⇚⇚', + 'Font Color': '⇚⇚Font Color⇚⇚', + 'Font Size': '⇚⇚Font Size⇚⇚', + 'Global Font': '⇚⇚Global Font⇚⇚', + 'Go back': '⇚Go back⇚', + "Go to the 'Create' tab to define traces.": + "⇚⇚⇚⇚⇚⇚⇚Go to the 'Create' tab to define traces.⇚⇚⇚⇚⇚⇚⇚", + 'Heads up!': '⇚⇚Heads up!⇚⇚', + Hide: '⇚Hide⇚', + Horizontal: '⇚⇚Horizontal⇚⇚', + 'Horizontal Positioning': '⇚⇚⇚⇚Horizontal Positioning⇚⇚⇚⇚', + 'IE only supports svg. Changing format to svg.': + '⇚⇚⇚⇚⇚⇚⇚⇚IE only supports svg. Changing format to svg.⇚⇚⇚⇚⇚⇚⇚⇚', + LaTeX: '⇚LaTeX⇚', + "LaTeX is a math typesetting language that doesn't work with rich text.": + "⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚LaTeX is a math typesetting language that doesn't work with rich text.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚", + 'Lasso Select': '⇚⇚Lasso Select⇚⇚', + Layout: '⇚Layout⇚', + Left: '⇚Left⇚', + Legend: '⇚Legend⇚', + 'Legend Box': '⇚⇚Legend Box⇚⇚', + 'Line Color': '⇚⇚Line Color⇚⇚', + 'Line Width': '⇚⇚Line Width⇚⇚', + Linear: '⇚Linear⇚', + Lines: '⇚Lines⇚', + "Looks like there aren't any traces defined yet.": + "⇚⇚⇚⇚⇚⇚⇚⇚Looks like there aren't any traces defined yet.⇚⇚⇚⇚⇚⇚⇚⇚", + 'Margin Color': '⇚⇚Margin Color⇚⇚', + 'Margins and Padding': '⇚⇚⇚Margins and Padding⇚⇚⇚', + Max: '⇚Max⇚', + Middle: '⇚Middle⇚', + Min: '⇚Min⇚', + 'Multiple Values': '⇚⇚⇚Multiple Values⇚⇚⇚', + Normal: '⇚Normal⇚', + 'Note Text': '⇚⇚Note Text⇚⇚', + Notes: '⇚Notes⇚', + Opacity: '⇚Opacity⇚', + 'Orbital rotation': '⇚⇚⇚Orbital rotation⇚⇚⇚', + Orientation: '⇚⇚Orientation⇚⇚', + Padding: '⇚Padding⇚', + Pan: '⇚Pan⇚', + 'Plot Background': '⇚⇚⇚Plot Background⇚⇚⇚', + Points: '⇚Points⇚', + Position: '⇚Position⇚', + Positioning: '⇚⇚Positioning⇚⇚', + 'Produced with Plotly': '⇚⇚⇚⇚Produced with Plotly⇚⇚⇚⇚', + Range: '⇚Range⇚', + 'Relative To': '⇚⇚Relative To⇚⇚', + Reset: '⇚Reset⇚', + 'Reset axes': '⇚⇚Reset axes⇚⇚', + 'Reset camera to default': '⇚⇚⇚⇚Reset camera to default⇚⇚⇚⇚', + 'Reset camera to last save': '⇚⇚⇚⇚Reset camera to last save⇚⇚⇚⇚', + 'Reset view': '⇚⇚Reset view⇚⇚', + 'Reset views': '⇚⇚Reset views⇚⇚', + 'Return to the Graph > Create menu above to add data.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚Return to the Graph > Create menu above to add data.⇚⇚⇚⇚⇚⇚⇚⇚⇚', + Reversed: '⇚Reversed⇚', + 'Rich Text': '⇚⇚Rich Text⇚⇚', + 'Rich text is incompatible with LaTeX.': + '⇚⇚⇚⇚⇚⇚Rich text is incompatible with LaTeX.⇚⇚⇚⇚⇚⇚', + Right: '⇚Right⇚', + Scale: '⇚Scale⇚', + Selection: '⇚⇚Selection⇚⇚', + Shape: '⇚Shape⇚', + Show: '⇚Show⇚', + 'Show closest data on hover': '⇚⇚⇚⇚⇚Show closest data on hover⇚⇚⇚⇚⇚', + Size: '⇚Size⇚', + 'Size and Spacing': '⇚⇚⇚Size and Spacing⇚⇚⇚', + 'Snapshot succeeded': '⇚⇚⇚Snapshot succeeded⇚⇚⇚', + 'Sorry, there was a problem downloading your snapshot!': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚Sorry, there was a problem downloading your snapshot!⇚⇚⇚⇚⇚⇚⇚⇚⇚', + Symbol: '⇚Symbol⇚', + 'Taking snapshot - this may take a few seconds': + '⇚⇚⇚⇚⇚⇚⇚⇚Taking snapshot - this may take a few seconds⇚⇚⇚⇚⇚⇚⇚⇚', + Text: '⇚Text⇚', + 'Text Attributes': '⇚⇚⇚Text Attributes⇚⇚⇚', + "The anchor point determines which side of the annotation's positioning coordinates refer to.": + "⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚The anchor point determines which side of the annotation's positioning coordinates refer to.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚", + 'The positioning inputs are relative to the anchor points on the text box.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚The positioning inputs are relative to the anchor points on the text box.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚', + 'This input has multiple values associated with it. Changing this setting will override these custom inputs.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚This input has multiple values associated with it. Changing this setting will override these custom inputs.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚', + 'This trace does not yet have any data.': + '⇚⇚⇚⇚⇚⇚⇚This trace does not yet have any data.⇚⇚⇚⇚⇚⇚⇚', + 'Tick Labels': '⇚⇚Tick Labels⇚⇚', + 'Tick Markers': '⇚⇚Tick Markers⇚⇚', + Title: '⇚Title⇚', + 'Title and Fonts': '⇚⇚⇚Title and Fonts⇚⇚⇚', + Titles: '⇚Titles⇚', + 'Toggle Spike Lines': '⇚⇚⇚Toggle Spike Lines⇚⇚⇚', + 'Toggle show closest data on hover': + '⇚⇚⇚⇚⇚⇚Toggle show closest data on hover⇚⇚⇚⇚⇚⇚', + Top: '⇚Top⇚', + Trace: '⇚Trace⇚', + 'Trace Order': '⇚⇚Trace Order⇚⇚', + 'Trace opacity is not supported for a scatter trace with fill or for a scatter trace that gets filled by another scatter trace.': + '⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚Trace opacity is not supported for a scatter trace with fill or for a scatter trace that gets filled by another scatter trace.⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚⇚', + 'Turntable rotation': '⇚⇚⇚Turntable rotation⇚⇚⇚', + Type: '⇚Type⇚', + Typeface: '⇚Typeface⇚', + URL: '⇚URL⇚', + Vertical: '⇚Vertical⇚', + 'Vertical Positioning': '⇚⇚⇚⇚Vertical Positioning⇚⇚⇚⇚', + Width: '⇚Width⇚', + 'X Position': '⇚⇚X Position⇚⇚', + 'X Vector': '⇚X Vector⇚', + 'Y Position': '⇚⇚Y Position⇚⇚', + 'Y Vector': '⇚Y Vector⇚', + Zoom: '⇚Zoom⇚', + 'Zoom Interactivity': '⇚⇚⇚Zoom Interactivity⇚⇚⇚', + 'Zoom in': '⇚Zoom in⇚', + 'Zoom out': '⇚Zoom out⇚', + 'close:': '⇚close:⇚', + 'high:': '⇚high:⇚', + 'incoming flow count:': '⇚⇚⇚⇚incoming flow count:⇚⇚⇚⇚', + 'kde:': '⇚kde:⇚', + 'lat:': '⇚lat:⇚', + log: '⇚log⇚', + 'lon:': '⇚lon:⇚', + 'low:': '⇚low:⇚', + 'lower fence:': '⇚⇚lower fence:⇚⇚', + 'max:': '⇚max:⇚', + 'mean ± σ:': '⇚⇚mean ± σ:⇚⇚', + 'mean:': '⇚mean:⇚', + 'median:': '⇚median:⇚', + 'min:': '⇚min:⇚', + 'open:': '⇚open:⇚', + 'outgoing flow count:': '⇚⇚⇚⇚outgoing flow count:⇚⇚⇚⇚', + 'q1:': '⇚q1:⇚', + 'q3:': '⇚q3:⇚', + 'source:': '⇚source:⇚', + 'target:': '⇚target:⇚', + trace: '⇚trace⇚', + 'upper fence:': '⇚⇚upper fence:⇚⇚', +};