mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 04:34:15 -04:00
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
import yargs from 'yargs';
|
|
import { hideBin } from 'yargs/helpers';
|
|
|
|
import { mergeTranslationProposals, createTranslationFiles } from '~~/helpers/translations/functions.ts';
|
|
import locales from '~~/locale/locales.ts';
|
|
|
|
yargs(hideBin(process.argv))
|
|
.scriptName('translations')
|
|
.help()
|
|
.showHidden()
|
|
.version()
|
|
.demandCommand()
|
|
.command(
|
|
'merge',
|
|
'Merge in pending translation changes',
|
|
(build) => {
|
|
return build
|
|
.options({
|
|
locale: {
|
|
alias: ['l'],
|
|
describe: 'Locale to be merged into',
|
|
demandOption: true,
|
|
type: 'string',
|
|
choices: locales.map((locale) => locale.code),
|
|
nargs: 1,
|
|
},
|
|
file: {
|
|
alias: ['f'],
|
|
describe: 'The file location of the pending translations',
|
|
demandOption: true,
|
|
type: 'string',
|
|
normalise: true,
|
|
nargs: 1,
|
|
},
|
|
})
|
|
.usage('$0 merge --locale <locale> --file <pending_file>');
|
|
},
|
|
async (args) => {
|
|
await mergeTranslationProposals(args.locale, args.file);
|
|
},
|
|
)
|
|
.command(
|
|
'create',
|
|
'Create a new language system',
|
|
(build) => {
|
|
return build
|
|
.options({
|
|
locale: {
|
|
alias: ['l'],
|
|
describe: 'Locale to be merged into',
|
|
demandOption: true,
|
|
type: 'string',
|
|
nargs: 1,
|
|
},
|
|
})
|
|
.usage('$0 create --locale <locale>');
|
|
},
|
|
async (args) => {
|
|
await createTranslationFiles(args.locale);
|
|
},
|
|
)
|
|
.example([
|
|
['$0 merge --locale en --file ./to-merge.suml', 'Merge pending translations into the English (en) locale'],
|
|
['$0 create --locale he', 'Create a new Hebrew (he) locale'],
|
|
])
|
|
.usage('$0 <command> [options]')
|
|
.showHelpOnFail(false, 'Specify --help for available options')
|
|
.wrap(null)
|
|
.parse();
|