mirror of
https://github.com/google/blockly.git
synced 2025-12-16 14:20:10 +01:00
Separate script to rebuild msg/json/en.json, qqq.json etc.
There are some files in msg/json/ (currently en.json, qqq.json,
constants.json and synonyms.json) that are generated by
scripts/i18n/js_to_json.py as part of the language file build process
- but this only needs to be done when messages.js is updated and
and usually requires some manual cleanup, so remove this step from the
existing buildLangfiles gulp script and create a separate command
('npm run generate:langfiles') to do this when required.
This commit is contained in:
@@ -23,6 +23,7 @@ var cleanupTasks = require('./scripts/gulpfiles/cleanup_tasks');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
deployDemos: appengineTasks.deployDemos,
|
deployDemos: appengineTasks.deployDemos,
|
||||||
default: buildTasks.build,
|
default: buildTasks.build,
|
||||||
|
generateLangfiles: buildTasks.generateLangfiles,
|
||||||
build: buildTasks.build,
|
build: buildTasks.build,
|
||||||
buildCore: buildTasks.core,
|
buildCore: buildTasks.core,
|
||||||
buildBlocks: buildTasks.blocks,
|
buildBlocks: buildTasks.blocks,
|
||||||
|
|||||||
@@ -8,13 +8,15 @@
|
|||||||
* @fileoverview English strings.
|
* @fileoverview English strings.
|
||||||
* @author fraser@google.com (Neil Fraser)
|
* @author fraser@google.com (Neil Fraser)
|
||||||
*
|
*
|
||||||
* After modifying this file, either run "build.py" from the parent directory,
|
* After modifying this file, run:
|
||||||
* or run (from this directory):
|
*
|
||||||
* ../scripts/i18n/js_to_json.py
|
* npm run generate:langfiles
|
||||||
* to regenerate json/{en,qqq,synonyms}.json.
|
*
|
||||||
|
* to regenerate json/{en,qqq,constants,synonyms}.json.
|
||||||
*
|
*
|
||||||
* To convert all of the json files to .js files, run:
|
* To convert all of the json files to .js files, run:
|
||||||
* ../scripts/i18n/create_messages.py json/*.json
|
*
|
||||||
|
* npm run build:langfiles
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
"deployDemos": "gulp deployDemos",
|
"deployDemos": "gulp deployDemos",
|
||||||
"format": "git-clang-format",
|
"format": "git-clang-format",
|
||||||
"format:sortrequires": "gulp sortRequires",
|
"format:sortrequires": "gulp sortRequires",
|
||||||
|
"generate:langfiles": "gulp generateLangfiles",
|
||||||
"license": "gulp checkLicenses",
|
"license": "gulp checkLicenses",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"package": "gulp package",
|
"package": "gulp package",
|
||||||
|
|||||||
@@ -408,18 +408,41 @@ goog.require('Blockly.requires');
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This task regenrates msg/json/en.js and msg/json/qqq.js from
|
||||||
|
* msg/messages.js.
|
||||||
|
*/
|
||||||
|
function generateLangfiles(done) {
|
||||||
|
// Run js_to_json.py
|
||||||
|
const jsToJsonCmd = `python scripts/i18n/js_to_json.py \
|
||||||
|
--input_file ${path.join('msg', 'messages.js')} \
|
||||||
|
--output_dir ${path.join('msg', 'json')} \
|
||||||
|
--quiet`;
|
||||||
|
execSync(jsToJsonCmd, { stdio: 'inherit' });
|
||||||
|
|
||||||
|
console.log(`
|
||||||
|
Regenerated several flies in msg/json/. Now run
|
||||||
|
|
||||||
|
git diff msg/json/*.json
|
||||||
|
|
||||||
|
and check that operation has not overwritten any modifications made to
|
||||||
|
hints, etc. by the TranslateWiki volunteers. If it has, backport
|
||||||
|
their changes to msg/messages.js and re-run 'npm run generate:langfiles'.
|
||||||
|
|
||||||
|
Once you are satisfied that any new hints have been backported you may
|
||||||
|
go ahead and commit the changes, but note that the generate script
|
||||||
|
will have removed the translator credits - be careful not to commit
|
||||||
|
this removal!
|
||||||
|
`);
|
||||||
|
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This task builds Blockly's lang files.
|
* This task builds Blockly's lang files.
|
||||||
* msg/*.js
|
* msg/*.js
|
||||||
*/
|
*/
|
||||||
function buildLangfiles(done) {
|
function buildLangfiles(done) {
|
||||||
// Run js_to_json.py
|
|
||||||
const jsToJsonCmd = `python ./scripts/i18n/js_to_json.py \
|
|
||||||
--input_file ${path.join('msg', 'messages.js')} \
|
|
||||||
--output_dir ${path.join('msg', 'json')} \
|
|
||||||
--quiet`;
|
|
||||||
execSync(jsToJsonCmd, { stdio: 'inherit' });
|
|
||||||
|
|
||||||
// Run create_messages.py
|
// Run create_messages.py
|
||||||
let json_files = fs.readdirSync(path.join('msg', 'json'));
|
let json_files = fs.readdirSync(path.join('msg', 'json'));
|
||||||
json_files = json_files.filter(file => file.endsWith('json') &&
|
json_files = json_files.filter(file => file.endsWith('json') &&
|
||||||
@@ -514,6 +537,7 @@ module.exports = {
|
|||||||
build: build,
|
build: build,
|
||||||
core: buildCore,
|
core: buildCore,
|
||||||
blocks: buildBlocks,
|
blocks: buildBlocks,
|
||||||
|
generateLangfiles: generateLangfiles,
|
||||||
langfiles: buildLangfiles,
|
langfiles: buildLangfiles,
|
||||||
uncompressed: buildUncompressed,
|
uncompressed: buildUncompressed,
|
||||||
compressed: buildCompressed,
|
compressed: buildCompressed,
|
||||||
|
|||||||
Reference in New Issue
Block a user