Skip to content
Snippets Groups Projects
Unverified Commit db58669f authored by chrisgarrity's avatar chrisgarrity Committed by GitHub
Browse files

Merge pull request #868 from chrisgarrity/l10n-update

Use scratch-ll10n for extracting strings
parents 76bde5a4 7a79ecc1
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"build": "npm run clean && webpack --progress --colors --bail", "build": "npm run clean && webpack --progress --colors --bail",
"clean": "rimraf ./build && mkdirp build", "clean": "rimraf ./build && mkdirp build",
"deploy": "touch build/.nojekyll && gh-pages -t -d build -m \"Build for $(git log --pretty=format:%H -n1)\"", "deploy": "touch build/.nojekyll && gh-pages -t -d build -m \"Build for $(git log --pretty=format:%H -n1)\"",
"i18n:src": "babel src > tmp.js && rimraf tmp.js && ./scripts/build-i18n-source.js ./translations/messages/ ./translations/", "i18n:src": "babel src > tmp.js && rimraf tmp.js && build-i18n-src ./translations/messages/ ./translations/",
"start": "webpack-dev-server", "start": "webpack-dev-server",
"test": "npm run test:lint && npm run test:unit && NODE_ENV=production npm run build && npm run test:integration", "test": "npm run test:lint && npm run test:unit && NODE_ENV=production npm run build && npm run test:integration",
"test:integration": "jest --runInBand test[\\\\/]integration", "test:integration": "jest --runInBand test[\\\\/]integration",
...@@ -28,11 +28,9 @@ ...@@ -28,11 +28,9 @@
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^7.1.3", "autoprefixer": "^7.1.3",
"babel-cli": "^6.26.0",
"babel-core": "^6.23.1", "babel-core": "^6.23.1",
"babel-eslint": "^8.0.1", "babel-eslint": "^8.0.1",
"babel-loader": "^7.1.0", "babel-loader": "^7.1.0",
"babel-plugin-react-intl": "^2.3.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-async-to-generator": "^6.24.1", "babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.22.0", "babel-plugin-transform-object-rest-spread": "^6.22.0",
......
#!/usr/bin/env node
const fs = require('fs');
const glob = require('glob');
const path = require('path');
const mkdirp = require('mkdirp');
var args = process.argv.slice(2);
if (!args.length) {
process.stdout.write('You must specify the messages dir generated by babel-plugin-react-intl.\n');
process.exit(1);
}
const MESSAGES_PATTERN = args.shift() + '/**/*.json';
if (!args.length) {
process.stdout.write('A destination directory must be specified.\n');
process.exit(1);
}
const LANG_DIR = args.shift();
// Aggregates the default messages that were extracted from the example app's
// React components via the React Intl Babel plugin. An error will be thrown if
// there are messages in different components that use the same `id`. The result
// is a chromei18n format collection of `id: {message: defaultMessage,
// description: description}` pairs for the app's default locale.
let defaultMessages = glob.sync(MESSAGES_PATTERN)
.map((filename) => fs.readFileSync(filename, 'utf8'))
.map((file) => JSON.parse(file))
.reduce((collection, descriptors) => {
descriptors.forEach(({id, defaultMessage, description}) => {
if (collection.hasOwnProperty(id)) {
throw new Error(`Duplicate message id: ${id}`);
}
collection[id] = {message: defaultMessage, description: description};
});
return collection;
}, {});
mkdirp.sync(LANG_DIR);
fs.writeFileSync(path.join(LANG_DIR, 'en.json'), JSON.stringify(defaultMessages, null, 2));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment