Translate text by many different translators.
Project description
translate-shell
Translate text by many different translators.
Usage
CLI
trans --translators=google,bing,haici,stardict crush
REPL
$ trans # enter REPL
> en:ja # change source language to english and target language to japanese
> : # swap source and target languages
> =stardict # use stardict to translate text
> !cat example/test.txt # execute a shell command
ハッカー
> <example/test.txt # translate a file
hacker
> 画家 # translate text
painter; artist
> ! # enter shell
$ echo $SHELL # execute a shell command
/usr/bin/zsh
$ exit # exit shell
>
TUI
Vim
:Translate --translators=google,bing Free as in Freedom
Script
Python
>>> from translate_shell.translate import translate
>>> translate("The Mythical Man-Month", "zh_TW")
... Translation(
... status=1,
... results=[
... {
... "translator": "google",
... "sl": "auto",
... "tl": "zh_TW",
... "text": "The Mythical Man-Month",
... "phonetic": "",
... "paraphrase": "人月神話",
... "explains": {},
... "details": {},
... "alternative": ["神话般的人月"],
... }
... ],
... text="The Mythical Man-Month",
... to_lang="zh_TW",
... from_lang="auto",
... )
Shell Script
$ xsel -o | trans --format json | jq -r '"《\(.results[].paraphrase)》的英文是 \(.text)."'
《大教堂和集市》的英文是 the cathedral and the bazaar.
Features
- Translate with different translators at same time, like translator
- Translate clipboard contents automatically, like ydcv
- Speak the pronunciation of words
- Support online translate engines
- Support offline dictionaries
- Many methods to use, from shell, python and vim
- Magic text, like
en:
to change source language,:zh_CN
to change target language,<file
to translate file, etc. - Allow customization by
config.py
- Good shell completions, especially for zsh, complete options and translation history
- Manpage:
man trans
- Beautiful UI
- Cross platforms
- Rich API, can be easily called from shell and python
- Good document
- Unit test, keep code quality
- CI/CD
- clean code
- Respect PEP484
- Respect PEP621
- Respect XDG
The last but not least: it is a libre software.
See document to know more.
PS: PR is welcome! Please make code clean and keep test pass!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
translate-shell-0.0.3.tar.gz
(61.9 kB
view details)
Built Distribution
File details
Details for the file translate-shell-0.0.3.tar.gz
.
File metadata
- Download URL: translate-shell-0.0.3.tar.gz
- Upload date:
- Size: 61.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41272c6d8ef64735f03e1e90c499a96b287a4cfa0b66dc6147ee4f2691c5f12 |
|
MD5 | fb3165f9cb045a6da4ef83903759e9b8 |
|
BLAKE2b-256 | a7358212eae865557faaebfa93fcc2b8f4210f95b15d00c3a0c871b580d990ec |
File details
Details for the file translate_shell-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: translate_shell-0.0.3-py3-none-any.whl
- Upload date:
- Size: 57.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9627b56aa5723c5904440e9f55bad546683d1e25c64cf9ff1fb5f9aa0a9bd0b6 |
|
MD5 | 4b774da90f6552c0b949d42ce6166e6e |
|
BLAKE2b-256 | 4c845b8c83c34547c533dbcbed16458ac5d9b0f3f8595d23eb8cd3c9d0e6bd3a |