From 8255ddb80d72ebf5b7a67a21b36a2474ecead347 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 6 May 2019 13:09:23 +0200 Subject: [PATCH] refactor(@embark/i18n): introduce embark-i18n package --- packages/embark-i18n/.npmrc | 4 ++ packages/embark-i18n/README.md | 6 ++ .../{embark => embark-i18n}/locales/en.json | 0 .../{embark => embark-i18n}/locales/es.json | 0 .../{embark => embark-i18n}/locales/fr.json | 0 .../{embark => embark-i18n}/locales/pt.json | 0 .../{embark => embark-i18n}/locales/sl.json | 0 packages/embark-i18n/package.json | 65 +++++++++++++++++++ .../i18n/i18n.ts => embark-i18n/src/index.ts} | 2 +- packages/embark-i18n/tsconfig.json | 4 ++ packages/embark-i18n/tslint.json | 3 + packages/embark-utils/src/accountParser.js | 1 + packages/embark/package.json | 1 + packages/embark/src/cmd/cmd.js | 2 +- .../blockchain_process/blockchainProcess.js | 2 +- packages/embark/src/test/accountParser.js | 2 +- .../src/test/modules/compiler/compiler.js | 2 +- 17 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 packages/embark-i18n/.npmrc create mode 100644 packages/embark-i18n/README.md rename packages/{embark => embark-i18n}/locales/en.json (100%) rename packages/{embark => embark-i18n}/locales/es.json (100%) rename packages/{embark => embark-i18n}/locales/fr.json (100%) rename packages/{embark => embark-i18n}/locales/pt.json (100%) rename packages/{embark => embark-i18n}/locales/sl.json (100%) create mode 100644 packages/embark-i18n/package.json rename packages/{embark/src/lib/core/i18n/i18n.ts => embark-i18n/src/index.ts} (94%) create mode 100644 packages/embark-i18n/tsconfig.json create mode 100644 packages/embark-i18n/tslint.json diff --git a/packages/embark-i18n/.npmrc b/packages/embark-i18n/.npmrc new file mode 100644 index 000000000..e031d3432 --- /dev/null +++ b/packages/embark-i18n/.npmrc @@ -0,0 +1,4 @@ +engine-strict = true +package-lock = false +save-exact = true +scripts-prepend-node-path = true diff --git a/packages/embark-i18n/README.md b/packages/embark-i18n/README.md new file mode 100644 index 000000000..8a1bfdcb5 --- /dev/null +++ b/packages/embark-i18n/README.md @@ -0,0 +1,6 @@ +# `embark-i18n` + +i18n support for Embark + +Visit [embark.status.im](https://embark.status.im/) to get started with +[Embark](https://github.com/embark-framework/embark). diff --git a/packages/embark/locales/en.json b/packages/embark-i18n/locales/en.json similarity index 100% rename from packages/embark/locales/en.json rename to packages/embark-i18n/locales/en.json diff --git a/packages/embark/locales/es.json b/packages/embark-i18n/locales/es.json similarity index 100% rename from packages/embark/locales/es.json rename to packages/embark-i18n/locales/es.json diff --git a/packages/embark/locales/fr.json b/packages/embark-i18n/locales/fr.json similarity index 100% rename from packages/embark/locales/fr.json rename to packages/embark-i18n/locales/fr.json diff --git a/packages/embark/locales/pt.json b/packages/embark-i18n/locales/pt.json similarity index 100% rename from packages/embark/locales/pt.json rename to packages/embark-i18n/locales/pt.json diff --git a/packages/embark/locales/sl.json b/packages/embark-i18n/locales/sl.json similarity index 100% rename from packages/embark/locales/sl.json rename to packages/embark-i18n/locales/sl.json diff --git a/packages/embark-i18n/package.json b/packages/embark-i18n/package.json new file mode 100644 index 000000000..52761c352 --- /dev/null +++ b/packages/embark-i18n/package.json @@ -0,0 +1,65 @@ +{ + "name": "embark-i18n", + "version": "4.1.0-beta.0", + "author": "Iuri Matias ", + "contributors": [], + "description": "i18n Support for Embark", + "homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-i18n#readme", + "bugs": "https://github.com/embark-framework/embark/issues", + "keywords": [ + "blockchain", + "dapps", + "ethereum", + "ipfs", + "serverless", + "solc", + "solidity" + ], + "files": [ + "dist" + ], + "license": "MIT", + "repository": { + "directory": "packages/embark-i18n", + "type": "git", + "url": "https://github.com/embark-framework/embark.git" + }, + "main": "./dist/index.js", + "scripts": { + "build": "cross-env BABEL_ENV=node babel src --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps", + "ci": "npm run qa", + "clean": "npm run reset", + "lint": "npm-run-all lint:*", + "lint:ts": "tslint -c tslint.json \"src/**/*.ts\"", + "package": "npm pack", + "// qa": "npm-run-all lint typecheck build package", + "qa": "npm-run-all lint build package", + "reset": "npx rimraf dist embark-*.tgz package", + "start": "npm run watch", + "typecheck": "tsc", + "watch": "run-p watch:*", + "watch:build": "npm run build -- --verbose --watch", + "watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch" + }, + "dependencies": { + "@babel/runtime-corejs2": "7.3.1", + "colors": "1.3.2", + "i18n": "0.8.3", + "os-locale": "2.1.0" + }, + "devDependencies": { + "@babel/cli": "7.2.3", + "@babel/core": "7.2.2", + "cross-env": "5.2.0", + "eslint": "5.7.0", + "npm-run-all": "4.1.5", + "rimraf": "2.6.3", + "tslint": "5.16.0", + "typescript": "3.4.5" + }, + "engines": { + "node": ">=8.12.0", + "npm": ">=6.4.1", + "yarn": ">=1.12.3" + } +} diff --git a/packages/embark/src/lib/core/i18n/i18n.ts b/packages/embark-i18n/src/index.ts similarity index 94% rename from packages/embark/src/lib/core/i18n/i18n.ts rename to packages/embark-i18n/src/index.ts index e8d040060..d996b38ca 100644 --- a/packages/embark/src/lib/core/i18n/i18n.ts +++ b/packages/embark-i18n/src/index.ts @@ -20,7 +20,7 @@ enum SupportedLanguage { const DEFAULT_LANGUAGE = SupportedLanguage.En; i18n.configure({ - directory: path.join(__dirname, "../../../../", "locales"), + directory: path.join(__dirname, "../", "locales"), locales: Object.values(SupportedLanguage), register: global, syncFiles: false, diff --git a/packages/embark-i18n/tsconfig.json b/packages/embark-i18n/tsconfig.json new file mode 100644 index 000000000..52d43eaaa --- /dev/null +++ b/packages/embark-i18n/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"] +} diff --git a/packages/embark-i18n/tslint.json b/packages/embark-i18n/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/embark-i18n/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/packages/embark-utils/src/accountParser.js b/packages/embark-utils/src/accountParser.js index c11edd174..145d6f8a1 100644 --- a/packages/embark-utils/src/accountParser.js +++ b/packages/embark-utils/src/accountParser.js @@ -1,3 +1,4 @@ +import { __ } from 'i18n'; const bip39 = require("bip39"); const hdkey = require('ethereumjs-wallet/hdkey'); const ethereumjsWallet = require('ethereumjs-wallet'); diff --git a/packages/embark/package.json b/packages/embark/package.json index 3907eb8f4..aa998c57d 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -101,6 +101,7 @@ "embark-core": "^4.1.0-beta.0", "embark-deployment": "^4.1.0-beta.0", "embark-ens": "^4.1.0-beta.0", + "embark-i18n": "^4.1.0-beta.0", "embark-library-manager": "^4.1.0-beta.0", "embark-logger": "^4.1.0-beta.0", "embark-plugin-cmd": "^4.1.0-beta.0", diff --git a/packages/embark/src/cmd/cmd.js b/packages/embark/src/cmd/cmd.js index 61b267770..fc4c2f248 100644 --- a/packages/embark/src/cmd/cmd.js +++ b/packages/embark/src/cmd/cmd.js @@ -1,6 +1,6 @@ +import * as i18n from 'embark-i18n'; const program = require('commander'); const EmbarkController = require('./cmd_controller.js'); -const i18n = require('../lib/core/i18n/i18n.js'); const fs = require('../lib/core/fs.js'); let embark = new EmbarkController(); diff --git a/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js b/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js index 08fe4614f..dd395040b 100644 --- a/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js +++ b/packages/embark/src/lib/modules/blockchain_process/blockchainProcess.js @@ -1,6 +1,6 @@ +import * as i18n from 'embark-i18n'; import { ProcessWrapper } from 'embark-core'; const BlockchainClient = require('./blockchain'); -const i18n = require('../../core/i18n/i18n.js'); const constants = require('embark-core/constants'); let blockchainProcess; diff --git a/packages/embark/src/test/accountParser.js b/packages/embark/src/test/accountParser.js index ae2c4f049..c51f18c6d 100644 --- a/packages/embark/src/test/accountParser.js +++ b/packages/embark/src/test/accountParser.js @@ -1,9 +1,9 @@ /*global __dirname, describe, it, before, after, require*/ +import * as i18n from 'embark-i18n'; const assert = require('assert'); const sinon = require('sinon'); let TestLogger = require('../lib/utils/test_logger'); const Web3 = require('web3'); -const i18n = require('../lib/core/i18n/i18n'); const fs = require('../lib/core/fs'); import { getWeiBalanceFromString, getHexBalanceFromString, AccountParser } from 'embark-utils'; i18n.setOrDetectLocale('en'); diff --git a/packages/embark/src/test/modules/compiler/compiler.js b/packages/embark/src/test/modules/compiler/compiler.js index dc63003cd..4c40c04c3 100644 --- a/packages/embark/src/test/modules/compiler/compiler.js +++ b/packages/embark/src/test/modules/compiler/compiler.js @@ -4,7 +4,7 @@ import { File, Types } from "../../../lib/core/file"; const assert = require('assert'); // TODO: need to rethink i18n and how that is required in each module -require('../../../lib/core/i18n/i18n'); +require('embark-i18n'); const Compiler = require('embark-compiler'); const Plugins = require('../../../lib/core/plugins.js');