A command line translator that integrates with Google Translate and Youdao Dict. Just for fun :)
Project description
Dict-tiny
A command line translator that integrates with Google Translate, DeepL Translator and Youdao Dict
Just for fun :)
Installation
You can install dict-tiny
via pip. (Python 3 only)
$ pip install dict-tiny
Upgrading
$ pip install --upgrade dict-tiny
Usage
Youdao Dict
$ dict-tiny book
>>> Youdao Dict <<<
book 英[bʊk]美[bʊk]
===================
n. 书籍;卷;账簿;名册;工作簿
vt. 预订;登记
n. (Book)人名;(中)卜(广东话·威妥玛);(朝)北;(英)布
$ dict-tiny 书
>>> Youdao Dict <<<
书 [shū]
=========
n.book;letter;script
vt.write
Use -m
/--more
to get more detail translation for word:
$ dict-tiny 曾经 -m
>>> Youdao Dict <<<
曾经 [céng jīng]
=================
adv.once;ever
more detail:
======== 副词 ========
1:
(表示有过某些行为或情况) once:
He once lived in Shanghai.
他曾经在上海住过。
She has taken part in a major battle for oil.
她曾经参加过石油大会战。
$ dict-tiny dictionary -m
>>> Youdao Dict <<<
dictionary 英['dɪkʃ(ə)n(ə)rɪ]美['dɪkʃə'nɛri]
=============================================
n. 字典;词典
more detail (collins):
======== N-COUNT 可数名词 ========
· 词典
A dictionary is a book in which the words and phrases of a language are listed alphabetically, together with their meanings or their translations in another language.
例: ...a Spanish-English dictionary.
…一本西班牙语—英语词典。
Note:
- Some words have a lot of translation that may occupy the entire screen.
- Only supports English or Chinese words currently.
Google Translate
Add -g
/ --google
to use Google Translate:
$ dict-tiny -g book
>>> Google Translate <<<
detected language: en
input: book
output: 书
Add --target-language
to specify what language you want to translate into:
$ dict-tiny -g book --target-language japanese
>>> Google Translate <<<
detected language: en
input: book
output: 本
Add --source-language
to specify what language you want to translate, but most of the time you don't need to do this because the API will automatically detect the language type.
So, of course, you can use it to detect the language type:
$ dict-tiny --detect-language book
>>> Google Translate <<<
confidence: 1
input: book
language: en
name: English
Note:
-
Make sure the google service is available in your network environment.
-
The source and target languages for Google Translate are identified using the iso-639-1 codes.
$ dict-tiny -g book --target-language zh --source-language en >>> Google Translate <<< input: book output: 书 source language: en
You can also enter the ISO language name:
$ dict-tiny -g book --target-language German --source-language English >>> Google Translate <<< input: book output: Buchen source language: English
Target language
- Setting the environment variable
$DICT_TINY_TARGET_LAN
to thetarget language
you prefer so that you do not have to specify thetarget language
every time.Dict-tiny
will first gettarget language
from$DICT_TINY_TARGET_LAN
. Giving the--target-language
switch on the command line will override the environment variable value. - The default
target-language
for Goole Translate areENGLISH_ISO_639='en'
if the content you input is not in English.
DeepL Translate
For some reason I am no longer allowed to use deepl pro, so deepl is no longer supported.
Default behavior
- Youdao Dict is the default translator, which means Youdao Dict will be used when no translator is specified.
- If the target language is not specified, Chinese or English will be set as the default target language.
Use clipboard content
Use -c
/--clipboard
to use the contents of the clipboard:
$ dict-tiny -c -y
>>> Youdao Dict <<<
encounter 英[ɪnˈkaʊntə(r)]美[ɪnˈkaʊntər]
=========================================
v. 遭遇;偶遇,邂逅
n. 偶遇,邂逅;经历,体验;冲突;比赛,交锋
$ dict-tiny -g -c
>>> Google Translate <<<
input: clipboard
output: 剪贴板
detected language: en
Note:
-c
/--clipboard
has low priority. If you add-c
and a word at the same time, the switch-c
will be ignored.
License
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
Built Distribution
File details
Details for the file dict-tiny-1.2.1.tar.gz
.
File metadata
- Download URL: dict-tiny-1.2.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c14feaea731b99fe1155bb48902b656ea4397ac7ab007a6a15e2c5aaefd09f2e |
|
MD5 | bad7a9e73e25fbeba4d1ff30e78760b7 |
|
BLAKE2b-256 | 409fb3894a0e602f81cfbe62e8589c383224a2a3faf94e7b4ef90cd0914e0059 |
File details
Details for the file dict_tiny-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: dict_tiny-1.2.1-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 527148940d998856b22fc5cf61faceffc346378e73cc2b35f4a51af6231ad364 |
|
MD5 | 8e2c2b6a8f38bd2823fcea4b763289d9 |
|
BLAKE2b-256 | f3be76ccf22479bda5cdb79b0ee14973d359946c61e9b26c4c6e75c6f233f52b |