-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Localization #2195
Changes from 1 commit
7e075f5
9a9de77
d859de5
7d057e5
8a5eeec
03dcb5d
bf2c6db
04ed6f0
0f8520e
5d6f267
97c0898
daf0884
4b48038
4b8f980
1275661
fc03cce
cb2f00c
97821e9
e80ec91
8b9e7d8
6029f94
9708b56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"moduleType": "locale", | ||
"name": "en-US", | ||
"dictionary": { | ||
"Click to enter Colorscale title": "Click to enter Colorscale title" | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"moduleType": "locale", | ||
"name": "en", | ||
"dictionary": { | ||
"Click to enter Colorscale title": "Click to enter Colourscale title" | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
var path = require('path'); | ||
var glob = require('glob'); | ||
|
||
var constants = require('./util/constants'); | ||
var common = require('./util/common'); | ||
var _bundle = require('./util/browserify_wrapper'); | ||
var makeSchema = require('./util/make_schema'); | ||
var wrapLocale = require('./util/wrap_locale'); | ||
/* | ||
* This script takes one argument | ||
* | ||
|
@@ -54,3 +58,13 @@ constants.partialBundlePaths.forEach(function(pathObj) { | |
pathToMinBundle: pathObj.distMin | ||
}); | ||
}); | ||
|
||
// "Browserify" the locales | ||
var localeGlob = path.join(constants.pathToLib, 'locale-*.json'); | ||
glob(localeGlob, function(err, files) { | ||
files.forEach(function(file) { | ||
var outName = 'plotly-' + path.basename(file).replace(/.json$/, '.js'); | ||
var outPath = path.join(constants.pathToDist, outName); | ||
wrapLocale(file, outPath); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @etpinard what do you think about this solution?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Requiring JSON files isn't ideal as described in #2195 (comment) I'd vote for converting those
great 👌
Lovely ❤️ and by the looks of it out push-to-cdn script should just worktm. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var minify = require('minify-stream'); | ||
var intoStream = require('into-stream'); | ||
var addStream = require('add-stream'); | ||
|
||
var constants = require('./constants'); | ||
|
||
var prefix = 'Plotly.register('; | ||
var suffix = ');'; | ||
|
||
/** Wrap a locale json file into a standalone js file | ||
* | ||
* @param {string} pathToInput path to the locale json file | ||
* @param {string} pathToOutput path to destination file | ||
* | ||
* Logs basename of bundle when completed. | ||
*/ | ||
module.exports = function wrap_locale(pathToInput, pathToOutput) { | ||
intoStream(prefix) | ||
.pipe(addStream(fs.createReadStream(pathToInput))) | ||
.pipe(addStream(intoStream(suffix))) | ||
.pipe(minify(constants.uglifyOptions)) | ||
.pipe(fs.createWriteStream(pathToOutput)) | ||
.on('finish', function() { | ||
logger(pathToOutput); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smooth work with |
||
}; | ||
|
||
function logger(pathToOutput) { | ||
var log = 'ok ' + path.basename(pathToOutput); | ||
|
||
console.log(log); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha. Webpack users won't like that. Webpack (v1 at least) needs a special loader to bundle JSON files unlike browserify. See #183
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, back to js 1275661