add locale option to most cmds

This commit is contained in:
Iuri Matias 2018-05-09 18:46:38 -04:00
parent 517a3bf234
commit 854fa0deb0

View File

@ -46,7 +46,9 @@ class Cmd {
.command('new [name]') .command('new [name]')
.description(__('New Application')) .description(__('New Application'))
.option('--simple', __('create a barebones project meant only for contract development')) .option('--simple', __('create a barebones project meant only for contract development'))
.option('--locale [locale]', __('language to use (default: en)'))
.action(function (name, options) { .action(function (name, options) {
i18n.setOrDetectLocale(options.locale);
if (name === undefined) { if (name === undefined) {
return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), { return promptly.prompt(__("Name your app (default is %s):", 'embarkDapp'), {
default: "embarkDApp", default: "embarkDApp",
@ -79,8 +81,10 @@ class Cmd {
demo() { demo() {
program program
.command('demo') .command('demo')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('create a working dapp with a SimpleStorage contract')) .description(__('create a working dapp with a SimpleStorage contract'))
.action(function () { .action(function () {
i18n.setOrDetectLocale(options.locale);
embark.generateTemplate('demo', './', 'embark_demo'); embark.generateTemplate('demo', './', 'embark_demo');
}); });
} }
@ -90,8 +94,10 @@ class Cmd {
.command('build [environment]') .command('build [environment]')
.option('--logfile [logfile]', __('filename to output logs (default: none)')) .option('--logfile [logfile]', __('filename to output logs (default: none)'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug') .option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('deploy and build dapp at ') + 'dist/ (default: development)') .description(__('deploy and build dapp at ') + 'dist/ (default: development)')
.action(function (env, _options) { .action(function (env, _options) {
i18n.setOrDetectLocale(options.locale);
_options.env = env || 'development'; _options.env = env || 'development';
_options.logFile = _options.logfile; // fix casing _options.logFile = _options.logfile; // fix casing
_options.logLevel = _options.loglevel; // fix casing _options.logLevel = _options.loglevel; // fix casing
@ -129,8 +135,10 @@ class Cmd {
program program
.command('blockchain [environment]') .command('blockchain [environment]')
.option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc')) .option('-c, --client [client]', __('Use a specific ethereum client or simulator (supported: %s)', 'geth, testrpc'))
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('run blockchain server (default: %s)', 'development')) .description(__('run blockchain server (default: %s)', 'development'))
.action(function (env, options) { .action(function (env, options) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig(env || 'development', { embark.initConfig(env || 'development', {
embarkConfig: 'embark.json', embarkConfig: 'embark.json',
interceptLogs: false interceptLogs: false
@ -149,8 +157,10 @@ class Cmd {
.option('-a, --accounts [numAccounts]', __('number of accounts (default: %s)', '10')) .option('-a, --accounts [numAccounts]', __('number of accounts (default: %s)', '10'))
.option('-e, --defaultBalanceEther [balance]', __('Amount of ether to assign each test account (default: %s)', '100')) .option('-e, --defaultBalanceEther [balance]', __('Amount of ether to assign each test account (default: %s)', '100'))
.option('-l, --gasLimit [gasLimit]', __('custom gas limit (default: %s)', '8000000')) .option('-l, --gasLimit [gasLimit]', __('custom gas limit (default: %s)', '8000000'))
.option('--locale [locale]', __('language to use (default: en)'))
.action(function (env, options) { .action(function (env, options) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig(env || 'development', { embark.initConfig(env || 'development', {
embarkConfig: 'embark.json', embarkConfig: 'embark.json',
interceptLogs: false interceptLogs: false
@ -168,8 +178,10 @@ class Cmd {
test() { test() {
program program
.command('test [file]') .command('test [file]')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('run tests')) .description(__('run tests'))
.action(function (file) { .action(function (file) {
i18n.setOrDetectLocale(options.locale);
embark.initConfig('development', { embark.initConfig('development', {
embarkConfig: 'embark.json', interceptLogs: false embarkConfig: 'embark.json', interceptLogs: false
}); });
@ -182,8 +194,10 @@ class Cmd {
.command('upload <platform> [environment]') .command('upload <platform> [environment]')
.option('--logfile [logfile]', __('filename to output logs (default: %s)', 'none')) .option('--logfile [logfile]', __('filename to output logs (default: %s)', 'none'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug') .option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'debug')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('Upload your dapp to a decentralized storage') + ' (e.g embark upload ipfs).') .description(__('Upload your dapp to a decentralized storage') + ' (e.g embark upload ipfs).')
.action(function (platform, env, _options) { .action(function (platform, env, _options) {
i18n.setOrDetectLocale(options.locale);
_options.env = env || 'development'; _options.env = env || 'development';
_options.logFile = _options.logfile; // fix casing _options.logFile = _options.logfile; // fix casing
_options.logLevel = _options.loglevel; // fix casing _options.logLevel = _options.loglevel; // fix casing
@ -197,8 +211,10 @@ class Cmd {
.option('--skip-undeployed', __('Graph will not include undeployed contracts')) .option('--skip-undeployed', __('Graph will not include undeployed contracts'))
.option('--skip-functions', __('Graph will not include functions')) .option('--skip-functions', __('Graph will not include functions'))
.option('--skip-events', __('Graph will not include events')) .option('--skip-events', __('Graph will not include events'))
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('generates documentation based on the smart contracts configured')) .description(__('generates documentation based on the smart contracts configured'))
.action(function (env, options) { .action(function (env, options) {
i18n.setOrDetectLocale(options.locale);
embark.graph({ embark.graph({
env: env || 'development', env: env || 'development',
logFile: options.logfile, logFile: options.logfile,
@ -212,8 +228,10 @@ class Cmd {
reset() { reset() {
program program
.command('reset') .command('reset')
.option('--locale [locale]', __('language to use (default: en)'))
.description(__('resets embarks state on this dapp including clearing cache')) .description(__('resets embarks state on this dapp including clearing cache'))
.action(function () { .action(function () {
i18n.setOrDetectLocale(options.locale);
embark.initConfig('development', { embark.initConfig('development', {
embarkConfig: 'embark.json', interceptLogs: false embarkConfig: 'embark.json', interceptLogs: false
}); });