-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslate.js
35 lines (30 loc) · 1.18 KB
/
translate.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
const yargs = require('yargs');
const translateGettext = require('./src/utils/translate/translateGettext.js');
const invokeArguments = yargs
.usage('Usage: translate [options]')
.example(
'translate -in=messages_de_de.po -out=messages_de_de -f -o',
'Writes all missing translations as fuzzy msgstrs into messages_de_de.' +
' Overwrites fuzzy messages.',
)
.boolean(['o', 'f'])
.default('fuzzy', false)
.default('overwrite', false)
.alias('o', 'overwrite')
.alias('f', 'fuzzy')
.alias('in', 'input')
.alias('out', 'output')
.describe('apiKey', 'DeepL API key')
.describe('in', 'Relative path to input file')
.alias('out', 'Relative path to output file')
.describe('f', 'Mark added translation as fuzzy')
.describe('o', 'Overwrite existing translations if they are marked as fuzzy')
.demandOption(['apiKey', 'input', 'output'])
.help('h')
.alias('h', 'help').argv;
console.log(`translating .po file: ${invokeArguments.input}`);
const callback = () => {
console.log(`writing to file: ${invokeArguments.output}`);
};
const { apiKey, input, fuzzy, overwrite, output } = invokeArguments;
translateGettext(apiKey, input, fuzzy, overwrite, callback, output);