diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index eeb76c4e..caff5677 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,14 +22,14 @@ There are two situations in which we create manual PRs to update translations: ### Adding a language -* [ ] Edit `src/supported-locales.js`: +* [ ] Edit `src/supported-locales.mjs`: * [ ] Add entry for the language in the `locales` const * [ ] Check if language is right-to-left. If so: * Add entry in `rtlLocales` * [ ] Check if the new language uses a country code * Check [https://www.transifex.com/explore/languages](https://www.transifex.com/explore/languages). If the language has a country code: - * [ ] Edit `src/supported-locales.js`: + * [ ] Edit `src/supported-locales.mjs`: * Add new entry to `localeMap`. Format is `'': ''` * [ ] Edit `.tx/config`: * Add to the `lang_map` list. Format is `:` @@ -42,14 +42,14 @@ There are two situations in which we create manual PRs to update translations: * [ ] Check if locale is in `react-intl` * Look in [https://unpkg.com/react-intl/locale-data/](https://unpkg.com/react-intl/locale-data/) * If not in `react-intl`: - * [ ] Edit `src/supported-locales.js`: + * [ ] Edit `src/supported-locales.mjs`: * In `customLocales`, add entry with parent set to a `react-intl` locale * [ ] Edit `src/index.js`: * In `localeData`, add entry for parent locale * [ ] Update translations per the "Updating translations" section above * [ ] Confirm that we see changes to: - * [ ] `src/supported-locales.js` + * [ ] `src/supported-locales.mjs` * [ ] `src/index.js` * [ ] `.tx/config` (if language needed a new locale) * [ ] Multiple files like `editor//.json` diff --git a/lib/transifex.js b/lib/transifex.js index ab5a76bf..c0244e7e 100644 --- a/lib/transifex.js +++ b/lib/transifex.js @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview diff --git a/lib/validate.js b/lib/validate.mjs similarity index 100% rename from lib/validate.js rename to lib/validate.mjs diff --git a/package.json b/package.json index fd6d3718..906002f5 100644 --- a/package.json +++ b/package.json @@ -10,31 +10,31 @@ }, "scripts": { "build": "npm run clean && npm run build:data && webpack --progress --colors --bail", - "build:data": "babel-node scripts/build-data", + "build:data": "node scripts/build-data.mjs", "clean": "rimraf ./dist ./locales && mkdirp dist locales", "lint": "npm run lint:js && npm run lint:json", - "lint:js": "eslint . --ext .js", + "lint:js": "eslint . --ext .js,.mjs,.cjs", "lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor", "prepare": "husky install", - "pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/", + "pull:blocks": "node scripts/tx-pull-editor.mjs scratch-editor blocks ./editor/blocks/", "pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface", - "pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/", + "pull:extensions": "node scripts/tx-pull-editor.mjs scratch-editor extensions ./editor/extensions/", "pull:help": "npm run pull:help:names && npm run pull:help:articles", "pull:help:articles": "./scripts/tx-pull-help-articles.js", "pull:help:names": "./scripts/tx-pull-help-names.js", - "pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/", - "pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/", - "pull:www": "babel-node scripts/tx-pull-www ./www", - "push:help": "./scripts/tx-push-help.js", + "pull:interface": "node scripts/tx-pull-editor.mjs scratch-editor interface ./editor/interface/", + "pull:paint": "node scripts/tx-pull-editor.mjs scratch-editor paint-editor ./editor/paint-editor/", + "pull:www": "node scripts/tx-pull-www.mjs ./www", + "push:help": "./scripts/tx-push-help.mjs", "sync:help": "npm run push:help && npm run pull:help", "test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json", "update": "scripts/update-translations.sh", - "validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/", + "validate:blocks": "node scripts/validate-translations.mjs ./editor/blocks/", "validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint", - "validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs", - "validate:interface": "babel-node scripts/validate-translations ./editor/interface/", - "validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/", - "validate:www": "babel-node scripts/validate-www ./www" + "validate:extensions": "node scripts/validate-translations.mjs ./editor/extensions/ && node scripts/validate-extension-inputs.mjs", + "validate:interface": "node scripts/validate-translations.mjs ./editor/interface/", + "validate:paint": "node scripts/validate-translations.mjs ./editor/paint-editor/", + "validate:www": "node scripts/validate-www.mjs ./www" }, "repository": { "type": "git", diff --git a/scripts/build-data.js b/scripts/build-data.mjs similarity index 98% rename from scripts/build-data.js rename to scripts/build-data.mjs index 8709706d..b6f12aaa 100755 --- a/scripts/build-data.js +++ b/scripts/build-data.mjs @@ -42,7 +42,7 @@ import * as fs from 'fs'; import * as path from 'path'; import {sync as mkdirpSync} from 'mkdirp'; import defaultsDeep from 'lodash.defaultsdeep'; -import locales from '../src/supported-locales.js'; +import locales from '../src/supported-locales.mjs'; const MSGS_DIR = './locales/'; mkdirpSync(MSGS_DIR); diff --git a/scripts/tx-pull-editor.js b/scripts/tx-pull-editor.mjs similarity index 94% rename from scripts/tx-pull-editor.js rename to scripts/tx-pull-editor.mjs index 3cb0c528..c1eff567 100644 --- a/scripts/tx-pull-editor.js +++ b/scripts/tx-pull-editor.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview @@ -29,8 +29,8 @@ if (!process.env.TX_TOKEN || args.length < 3) { import fs from 'fs'; import path from 'path'; import {txPull} from '../lib/transifex.js'; -import {validateTranslations} from '../lib/validate.js'; -import locales, {localeMap} from '../src/supported-locales.js'; +import {validateTranslations} from '../lib/validate.mjs'; +import locales, {localeMap} from '../src/supported-locales.mjs'; import {batchMap} from '../lib/batch.js'; // Globals diff --git a/scripts/tx-pull-www.js b/scripts/tx-pull-www.mjs similarity index 97% rename from scripts/tx-pull-www.js rename to scripts/tx-pull-www.mjs index 585ce09f..dbff18d9 100755 --- a/scripts/tx-pull-www.js +++ b/scripts/tx-pull-www.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview @@ -31,7 +31,7 @@ import fs from 'fs'; import path from 'path'; import mkdirp from 'mkdirp'; import {txPull, txResources} from '../lib/transifex.js'; -import locales, {localeMap} from '../src/supported-locales.js'; +import locales, {localeMap} from '../src/supported-locales.mjs'; import {batchMap} from '../lib/batch.js'; // Globals diff --git a/scripts/tx-push-help.js b/scripts/tx-push-help.mjs similarity index 99% rename from scripts/tx-push-help.js rename to scripts/tx-push-help.mjs index 7109b699..bfbb9099 100755 --- a/scripts/tx-push-help.js +++ b/scripts/tx-push-help.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview diff --git a/scripts/validate-extension-inputs.js b/scripts/validate-extension-inputs.mjs similarity index 97% rename from scripts/validate-extension-inputs.js rename to scripts/validate-extension-inputs.mjs index 9a374e87..5d6ce61d 100644 --- a/scripts/validate-extension-inputs.js +++ b/scripts/validate-extension-inputs.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview @@ -9,7 +9,7 @@ import fs from 'fs'; import path from 'path'; import async from 'async'; import assert from 'assert'; -import locales from '../src/supported-locales.js'; +import locales from '../src/supported-locales.mjs'; // Globals const JSON_DIR = path.join(process.cwd(), '/editor/extensions'); diff --git a/scripts/validate-translations.js b/scripts/validate-translations.mjs similarity index 86% rename from scripts/validate-translations.js rename to scripts/validate-translations.mjs index d2e24fd8..ee4654ce 100644 --- a/scripts/validate-translations.js +++ b/scripts/validate-translations.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview @@ -8,7 +8,7 @@ const args = process.argv.slice(2); const usage = ` Validate translation json. Usage: - babel-node validate_translations.js path + node validate_translations.mjs path path: where to find the downloaded json files `; // Fail immediately if the TX_TOKEN is not defined @@ -19,8 +19,8 @@ if (args.length < 1) { import fs from 'fs'; import path from 'path'; import async from 'async'; -import {validateTranslations} from '../lib/validate.js'; -import locales from '../src/supported-locales.js'; +import {validateTranslations} from '../lib/validate.mjs'; +import locales from '../src/supported-locales.mjs'; // Globals const JSON_DIR = path.resolve(args[0]); diff --git a/scripts/validate-www.js b/scripts/validate-www.mjs similarity index 90% rename from scripts/validate-www.js rename to scripts/validate-www.mjs index 0a5bbff0..e8454083 100755 --- a/scripts/validate-www.js +++ b/scripts/validate-www.mjs @@ -1,4 +1,4 @@ -#!/usr/bin/env babel-node +#!/usr/bin/env node /** * @fileoverview @@ -8,7 +8,7 @@ const args = process.argv.slice(2); const usage = ` Validate translation json. Usage: - babel-node validate_www.js path + node validate_www.mjs path path: root folder for all the www resource folders `; if (args.length < 1) { @@ -19,8 +19,8 @@ import fs from 'fs'; import path from 'path'; import glob from 'glob'; import async from 'async'; -import {validateTranslations} from '../lib/validate.js'; -import locales from '../src/supported-locales.js'; +import {validateTranslations} from '../lib/validate.mjs'; +import locales from '../src/supported-locales.mjs'; // Globals const WWW_DIR = path.resolve(args[0]); diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 43007c05..00000000 --- a/src/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import localeData from './locale-data.js'; -import locales, {localeMap, isRtl} from './supported-locales.js'; -export {locales as default, localeData, localeMap, isRtl}; diff --git a/src/index.mjs b/src/index.mjs new file mode 100644 index 00000000..444dd78b --- /dev/null +++ b/src/index.mjs @@ -0,0 +1,3 @@ +import localeData from './locale-data.mjs'; +import locales, {localeMap, isRtl} from './supported-locales.mjs'; +export {locales as default, localeData, localeMap, isRtl}; diff --git a/src/locale-data.js b/src/locale-data.mjs similarity index 98% rename from src/locale-data.js rename to src/locale-data.mjs index 49b366fc..949f863f 100644 --- a/src/locale-data.js +++ b/src/locale-data.mjs @@ -72,7 +72,7 @@ import xh from './locale-data/xh'; import zh from './locale-data/zh'; import zu from './locale-data/zu'; -import {customLocales} from './supported-locales.js'; +import {customLocales} from './supported-locales.mjs'; let localeData = [].concat( en, diff --git a/src/supported-locales.js b/src/supported-locales.mjs similarity index 100% rename from src/supported-locales.js rename to src/supported-locales.mjs diff --git a/webpack.config.js b/webpack.config.js index 878b83d7..25735e40 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -22,8 +22,8 @@ module.exports = { }, entry: { l10n: './src/index.js', - supportedLocales: './src/supported-locales.js', - localeData: './src/locale-data.js' + supportedLocales: './src/supported-locales.mjs', + localeData: './src/locale-data.mjs' }, output: { path: path.resolve(__dirname, 'dist'),