Use web translation service in terminal, without requiring any additional API registration.
- puppeteer-core: core library of puppeteer, headless Chrome
- commander: argument options parser
npm i puppeteer-core commander
Usage: ./translate.js [-p <path>] [-f <from_lang] [-t <to_lang>] [-s <service>] <text>
Options:
-p, --path <binary_path> path to chrome/chromium binary
default "/usr/bin/chromium"
-f, --from <lang_iso> language ISO code of text to translate
default "en"
-t, --to <lang_iso> language ISO code of target language
default "en"
-s, --service <service> supported service: google, deepl
default "goodle"
-h, --help display help for command
- Translate text to EN:
$ ./translate.js Schnappi Das Kleine Krokodil
Schnappi the little crocodil
- Translate text to DE:
$ ./translate.js -t de 'Hold my beer'
Halte mein Bier
- Translate text to Simplified Chinese, using DeepL:
$ ./translate.js -t zh -s deepl 'stay the fuck home'
宅在家里