diff --git a/package.json b/package.json index 9a1119fbff8ac4941b5c9212607952b23b6ba096..09d176b74cd5bc5b4d3773390bfca6eabfc1997a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "npm run clean && webpack --progress --colors --bail", "clean": "rimraf ./build && mkdirp build", "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", "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", @@ -28,11 +28,9 @@ }, "devDependencies": { "autoprefixer": "^7.1.3", - "babel-cli": "^6.26.0", "babel-core": "^6.23.1", "babel-eslint": "^8.0.1", "babel-loader": "^7.1.0", - "babel-plugin-react-intl": "^2.3.1", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-async-to-generator": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.22.0", diff --git a/scripts/build-i18n-source.js b/scripts/build-i18n-source.js deleted file mode 100755 index 9f6571c1c3fa39fa2918744eb84221f8e546d057..0000000000000000000000000000000000000000 --- a/scripts/build-i18n-source.js +++ /dev/null @@ -1,45 +0,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));