npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kabeep/node-translate-cli

v1.2.0

Published

A powerful, secure and feature-rich tool via Google Translation in terminal.

Downloads

22

Readme

A powerful, secure and feature-rich tool via Google Translation in terminal.


NodeJS License NPM Codecov Codacy CircleCI

English | 简体中文

Alt

📖 Introduction

Using the node-translate API in the terminal.

The API bypasses token restrictions. If it is used in large quantities or for business, please support the work of Google Translation, which provides a lot of free credits.

Besides simple text translation, it also provides:

  • Auto-detect system language as target language
  • Spell autocorrect
  • Getting source text from stdin
  • Polysemous translation results
  • Synonyms of the source text
  • Example sentences of the source text
  • Phonetic transcription of the source and translated text
  • Stable output and error prompts
  • Beautiful terminal styling
  • Internationalized prompt for terminal

⚙️ Installation

npm install @kabeep/node-translate-cli --save
yarn add @kabeep/node-translate-cli
pnpm add @kabeep/node-translate-cli

🚀 Usage

translate <text> [options]

options:
  -f, --from            The source language (language to be translated from)
                        specified as language name or ISO 639-1 code
                                                           [string] [default: "auto"]
  -t, --to              The target language (language to be translated to)
                        specified as language name or ISO 639-1 code
                                                           [string] [default: "auto"]
      --timeout         Timeout duration for the translation request in
                        milliseconds                       [number] [default: 30000]
      --stdin-timeout   You can use this parameter to avoid timeouts if stdin
                        takes too long (ms)                [number] [default: 5000]
  -r, --retry           Retry attempts for the translation request in case of
                        failure                            [number] [default: 0]
  -p, --show-phonetics  Show the pronunciation of the translated word
                                                           [boolean] [default: false]
  -s, --show-source     Show source text information       [boolean] [default: false]
  -d, --show-detail     Show translated detail information [boolean] [default: false]
  -l, --show-list       Show supported language list       [boolean] [default: false]
      --show-code       Show supported language code list  [boolean] [default: false]
      --show-adaptive   Show adaptive language             [boolean] [default: false]
  -v, --version         Show version                       [boolean]
  -h, --help            Show help info                     [boolean]

🪄 Examples

Using stdin

echo "test" | translate -f en -t zh

Using iso-639-1 and text parameters

translate "test" --from=en --to=zh

Using language name and capitalized correction

translate "test" --from="ENGLISH" --to="chinese"

Adaptive source language

translate "test" -t zh

Self-detection of native language

translate "test" -f en

Autocorrect source text

translate "Thunk you"

Translate words and show synonyms, polysemy explanations and examples

translate "test" -d

Translate a word, phrase or sentence and show the source text and phonetic symbols

translate "test" -s -p

Set API timeout

translate "test" --timeout=60000

Set the timeout for the standard input stream

npm view node-translate-cli description | translate --stdin-timeout=30000

Set the number of retries when an API request fails

translate "test" -r 2

Show supported languages

translate -l

Show supported language codes

translate --show-code

Show supported adaptive languages

translate --show-adaptive

Show help information

translate -h

Show the version of current

translate -v

🧙🏽‍♂️ Advanced

Using another npm package

npm install -g clipboard-cli

# Use the clipboard-cli to copy translation results to the clipboard
translate 'Translate this sentence to your clipboard' | clipboard

Using the static accessor $() method

git commit -m "$(translate 'feat: your commit content' -t zh)"

Alt

Using the pipe | symbol

npm info npm description | translate -t zh

Alt

Using the redirection > symbol

translate "这是一段测试文本。" -t en > usage.txt

Alt

🔧 Autocorrect

Default: white background

Correct Spelling: yellow background

Detect Language: red background

Alt

🐢 Network anomaly

When the network is abnormal, the terminal will change as shown in the figure below (they actually come from the same line).

Alt

⌨️ Automatic line wrapping

When a single line of content is too long, the terminal will automatically wrap the line after the title.

Alt

🌐 i18n

Quickly contribute your language via ease-to-use node-translate-i18n in locale file are welcome, or notify me via Issues for handling.

Alt

🔗 Related

🤝 Contribution

Contributions via Pull Requests or Issues are welcome.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.