refactor(localize): update yargs and typings for yargs (#38470)
Updating yargs and typings for the updated yargs module. PR Close #38470
This commit is contained in:
parent
301513311e
commit
8373b720f3
|
@ -30,12 +30,14 @@ if (require.main === module) {
|
|||
alias: 'locale',
|
||||
describe: 'The locale of the source being processed',
|
||||
default: 'en',
|
||||
type: 'string',
|
||||
})
|
||||
.option('r', {
|
||||
alias: 'root',
|
||||
default: '.',
|
||||
describe: 'The root path for other paths provided in these options.\n' +
|
||||
'This should either be absolute or relative to the current working directory.'
|
||||
'This should either be absolute or relative to the current working directory.',
|
||||
type: 'string',
|
||||
})
|
||||
.option('s', {
|
||||
alias: 'source',
|
||||
|
@ -43,40 +45,45 @@ if (require.main === module) {
|
|||
describe:
|
||||
'A glob pattern indicating what files to search for translations, e.g. `./dist/**/*.js`.\n' +
|
||||
'This should be relative to the root path.',
|
||||
type: 'string',
|
||||
})
|
||||
.option('f', {
|
||||
alias: 'format',
|
||||
required: true,
|
||||
choices: ['xmb', 'xlf', 'xlif', 'xliff', 'xlf2', 'xlif2', 'xliff2', 'json'],
|
||||
describe: 'The format of the translation file.',
|
||||
type: 'string',
|
||||
})
|
||||
.option('o', {
|
||||
alias: 'outputPath',
|
||||
required: true,
|
||||
describe:
|
||||
'A path to where the translation file will be written. This should be relative to the root path.'
|
||||
'A path to where the translation file will be written. This should be relative to the root path.',
|
||||
type: 'string',
|
||||
})
|
||||
.option('loglevel', {
|
||||
describe: 'The lowest severity logging message that should be output.',
|
||||
choices: ['debug', 'info', 'warn', 'error'],
|
||||
type: 'string',
|
||||
})
|
||||
.option('useSourceMaps', {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
describe:
|
||||
'Whether to generate source information in the output files by following source-map mappings found in the source files'
|
||||
'Whether to generate source information in the output files by following source-map mappings found in the source files',
|
||||
})
|
||||
.option('useLegacyIds', {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
describe:
|
||||
'Whether to use the legacy id format for messages that were extracted from Angular templates.'
|
||||
'Whether to use the legacy id format for messages that were extracted from Angular templates.',
|
||||
})
|
||||
.option('d', {
|
||||
alias: 'duplicateMessageHandling',
|
||||
describe: 'How to handle messages with the same id but different text.',
|
||||
choices: ['error', 'warning', 'ignore'],
|
||||
default: 'warning',
|
||||
type: 'string',
|
||||
})
|
||||
.strict()
|
||||
.help()
|
||||
|
@ -85,22 +92,22 @@ if (require.main === module) {
|
|||
const fs = new NodeJSFileSystem();
|
||||
setFileSystem(fs);
|
||||
|
||||
const rootPath = options['root'];
|
||||
const sourceFilePaths = glob.sync(options['source'], {cwd: rootPath, nodir: true});
|
||||
const logLevel = options['loglevel'] as (keyof typeof LogLevel) | undefined;
|
||||
const rootPath = options.r;
|
||||
const sourceFilePaths = glob.sync(options.s, {cwd: rootPath, nodir: true});
|
||||
const logLevel = options.loglevel as (keyof typeof LogLevel) | undefined;
|
||||
const logger = new ConsoleLogger(logLevel ? LogLevel[logLevel] : LogLevel.warn);
|
||||
const duplicateMessageHandling: DiagnosticHandlingStrategy = options['d'];
|
||||
const duplicateMessageHandling = options.d as DiagnosticHandlingStrategy;
|
||||
|
||||
|
||||
extractTranslations({
|
||||
rootPath,
|
||||
sourceFilePaths,
|
||||
sourceLocale: options['locale'],
|
||||
format: options['format'],
|
||||
outputPath: options['outputPath'],
|
||||
sourceLocale: options.l,
|
||||
format: options.f,
|
||||
outputPath: options.o,
|
||||
logger,
|
||||
useSourceMaps: options['useSourceMaps'],
|
||||
useLegacyIds: options['useLegacyIds'],
|
||||
useSourceMaps: options.useSourceMaps,
|
||||
useLegacyIds: options.useLegacyIds,
|
||||
duplicateMessageHandling,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -30,18 +30,21 @@ if (require.main === module) {
|
|||
required: true,
|
||||
describe:
|
||||
'The root path of the files to translate, either absolute or relative to the current working directory. E.g. `dist/en`.',
|
||||
type: 'string',
|
||||
})
|
||||
.option('s', {
|
||||
alias: 'source',
|
||||
required: true,
|
||||
describe:
|
||||
'A glob pattern indicating what files to translate, relative to the `root` path. E.g. `bundles/**/*`.',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('l', {
|
||||
alias: 'source-locale',
|
||||
describe:
|
||||
'The source locale of the application. If this is provided then a copy of the application will be created with no translation but just the `$localize` calls stripped out.',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('t', {
|
||||
|
@ -54,6 +57,7 @@ if (require.main === module) {
|
|||
'If you want to merge multiple translation files for each locale, then provide the list of files in an array.\n' +
|
||||
'Note that the arrays must be in double quotes if you include any whitespace within the array.\n' +
|
||||
'E.g. `-t "[src/locale/messages.en.xlf, src/locale/messages-2.en.xlf]" [src/locale/messages.fr.xlf,src/locale/messages-2.fr.xlf]`',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('target-locales', {
|
||||
|
@ -61,6 +65,7 @@ if (require.main === module) {
|
|||
describe:
|
||||
'A list of target locales for the translation files, which will override any target locale parsed from the translation file.\n' +
|
||||
'E.g. "-t en fr de".',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('o', {
|
||||
|
@ -68,7 +73,8 @@ if (require.main === module) {
|
|||
required: true,
|
||||
describe: 'A output path pattern to where the translated files will be written.\n' +
|
||||
'The path must be either absolute or relative to the current working directory.\n' +
|
||||
'The marker `{{LOCALE}}` will be replaced with the target locale. E.g. `dist/{{LOCALE}}`.'
|
||||
'The marker `{{LOCALE}}` will be replaced with the target locale. E.g. `dist/{{LOCALE}}`.',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('m', {
|
||||
|
@ -76,6 +82,7 @@ if (require.main === module) {
|
|||
describe: 'How to handle missing translations.',
|
||||
choices: ['error', 'warning', 'ignore'],
|
||||
default: 'warning',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.option('d', {
|
||||
|
@ -83,6 +90,7 @@ if (require.main === module) {
|
|||
describe: 'How to handle duplicate translations.',
|
||||
choices: ['error', 'warning', 'ignore'],
|
||||
default: 'warning',
|
||||
type: 'string',
|
||||
})
|
||||
|
||||
.strict()
|
||||
|
@ -92,14 +100,14 @@ if (require.main === module) {
|
|||
const fs = new NodeJSFileSystem();
|
||||
setFileSystem(fs);
|
||||
|
||||
const sourceRootPath = options['r'];
|
||||
const sourceFilePaths = glob.sync(options['s'], {cwd: sourceRootPath, nodir: true});
|
||||
const translationFilePaths: (string|string[])[] = convertArraysFromArgs(options['t']);
|
||||
const outputPathFn = getOutputPathFn(fs.resolve(options['o']));
|
||||
const sourceRootPath = options.r;
|
||||
const sourceFilePaths = glob.sync(options.s, {cwd: sourceRootPath, nodir: true});
|
||||
const translationFilePaths: (string|string[])[] = convertArraysFromArgs(options.t);
|
||||
const outputPathFn = getOutputPathFn(fs.resolve(options.o));
|
||||
const diagnostics = new Diagnostics();
|
||||
const missingTranslation: DiagnosticHandlingStrategy = options['m'];
|
||||
const duplicateTranslation: DiagnosticHandlingStrategy = options['d'];
|
||||
const sourceLocale: string|undefined = options['l'];
|
||||
const missingTranslation = options.m as DiagnosticHandlingStrategy;
|
||||
const duplicateTranslation = options.d as DiagnosticHandlingStrategy;
|
||||
const sourceLocale: string|undefined = options.l;
|
||||
const translationFileLocales: string[] = options['target-locales'] || [];
|
||||
|
||||
translateFiles({
|
||||
|
|
Loading…
Reference in New Issue