-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcommands.js
executable file
·72 lines (59 loc) · 2.05 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env node
let pjson = require('./package.json')
const program = require('commander')
const {
createCSV,
generate,
langSwitcher,
listCodes
} = require('./index.js')
const helpText = `
Getting Started
===============
Step 1. Create a sample CSV file (/translations.csv):
$ quasalang create-csv
Step 2. Add your own languages & phrases to /translations.csv
Step 3. Generate your language files:
$ quasalang generate
`
program
.version(pjson.version)
.description('Generate Quasar i18n language files from a CSV file. Run it from the root of a Quasar project.')
.addHelpText('after', helpText)
program
.command('generate')
.alias('g')
.option('-i, --input <mode>', 'Path to input CSV', 'translations.csv')
.option('-o, --output <mode>', 'Path to i18n output folder', 'src/i18n')
.option('-f, --force', 'Force write files (without prompt)', false)
.option('-nw, --nowatermark', 'Disable the watermark ("This file was auto-generated..") ', false)
.option('-ls, --lang-switcher', `Generate language switcher options array & output to console i.e. [{ label: 'English', value: 'en-US'}, ..]`, false)
.option('-w, --watch', `Watch CSV file for changes & regenerate files`, false)
.description('Generate your i18n folder & all language files based on a CSV file')
.action((options) => {
generate(options)
})
program
.command('create-csv')
.alias('c')
.option('-f, --force', 'Force overwrite translations file (without prompt)', false)
.description('Create a sample CSV file (/translations.csv)')
.action((options) => {
createCSV(options)
})
program
.command('lang-switcher')
.alias('ls')
.option('-i, --input <mode>', 'Path to input CSV', 'translations.csv')
.description(`Generate language switcher options array & output to console i.e. [{ label: 'English', value: 'en-US'}, ..]`)
.action((options) => {
langSwitcher(options)
})
program
.command('list-codes')
.alias('lc')
.description(`Search & list i18n locale codes`)
.action((options) => {
listCodes(options)
})
program.parse(process.argv)