trnaslationRunner: import yargs
This commit is contained in:
parent
141241ab2c
commit
73315e4095
1 changed files with 5 additions and 3 deletions
|
@ -3,6 +3,7 @@ import path from 'path';
|
||||||
|
|
||||||
import * as parser from 'intl-messageformat-parser';
|
import * as parser from 'intl-messageformat-parser';
|
||||||
import manageTranslations, { readMessageFiles, ExtractedDescriptor } from 'react-intl-translations-manager';
|
import manageTranslations, { readMessageFiles, ExtractedDescriptor } from 'react-intl-translations-manager';
|
||||||
|
import yargs from 'yargs';
|
||||||
|
|
||||||
type Validator = (language: string) => void;
|
type Validator = (language: string) => void;
|
||||||
|
|
||||||
|
@ -68,14 +69,15 @@ Available languages:
|
||||||
${availableLanguages.join(', ')}
|
${availableLanguages.join(', ')}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const { argv } = require('yargs')
|
const argv = yargs
|
||||||
.usage(usage)
|
.usage(usage)
|
||||||
.option('f', {
|
.option('f', {
|
||||||
alias: 'force',
|
alias: 'force',
|
||||||
default: false,
|
default: false,
|
||||||
describe: 'force using the provided languages. create files if not exists.',
|
describe: 'force using the provided languages. create files if not exists.',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
});
|
})
|
||||||
|
.parseSync();
|
||||||
|
|
||||||
// check if message directory exists
|
// check if message directory exists
|
||||||
if (!fs.existsSync(messagesDirectory)) {
|
if (!fs.existsSync(messagesDirectory)) {
|
||||||
|
@ -87,7 +89,7 @@ Try to run "yarn build" first`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine the languages list
|
// determine the languages list
|
||||||
const languages: string[] = (argv._.length > 0) ? argv._ : availableLanguages;
|
const languages: string[] = (argv._.length > 0) ? argv._.map(String) : availableLanguages;
|
||||||
|
|
||||||
const validators: Validator[] = [
|
const validators: Validator[] = [
|
||||||
testRFC5646,
|
testRFC5646,
|
||||||
|
|
Loading…
Reference in a new issue