A tiny command-line dictionary and translator implemented in Plumbum. Youdao.com and Google Translation API. Just for fun :)
Project description
Dict-tiny
A command-line utility that can be used as:
- A dictionary of Chinese and English word translation by getting the data of youdao.com.
- A translator by using Google Translation API. You can also use it to detect the language type.
Just for fun :)
Installation
You can install dict-tiny
via the pip package manager. (Python 3 only)
$ pip install dict-tiny
Upgrading
$ pip install --upgrade dict-tiny
Usage
Translate an English word or Chinese word
$ dict-tiny book
book 英[bʊk]美[bʊk]
===================
n. 书籍;卷;账簿;名册;工作簿
vt. 预订;登记
n. (Book)人名;(中)卜(广东话·威妥玛);(朝)北;(英)布
$ dict-tiny 书
书 [shū]
=========
n.book;letter;script
vt.write
Get more detail translation about the word
Use -m
/--more
to get more detail translation:
$ dict-tiny 曾经 -m
曾经 [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
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:
- You can use
-c
and-m
at the same time, which means get more detail translation about the word in clipboard. - Some words have a lot of translation that may occupy the entire screen.
Using Google Translation API
Adding -g
to use Google Translation API:
$ dict-tiny -g book
detectedSourceLanguage: en
input: book
translatedText: 书
Adding --target-language
to specify what language you want to translate into:
$ dict-tiny -g book --target-language japanese
detectedSourceLanguage: en
input: book
translatedText: 本
Adding --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
confidence: 1
input: book
language: en
name: Armenian
Note:
-
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. -
If your input is a sentence or more than one word, the Google Translation API will be called automatically. In other word, you don't need to manually add -g when you type a sentence.
-
The source and target languages are identified using the iso-639-1 codes.
$ dict-tiny -g book --target-language zh --source-language en input: book translatedText: 书
You can also enter the ISO language name:
$ dict-tiny -g book --target-language chinese --source-language english input: book translatedText: 书
Translate the word in clipboard
Use -c
/--clipboard
to translate the word in clipboard:
$ dict-tiny -c
命令行
======
command line
If you want to use -g
you need to put it before -c
.
$ dict-tiny -g -c
detectedSourceLanguage: en
input: clipboard
translatedText: 剪贴板
Note:
-c
/--clipboard
has high priority. If you add-c
and a word at the same time, the word will be ignored.
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-0.3.1.tar.gz
.
File metadata
- Download URL: dict-tiny-0.3.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbf9eb521a0e3bae967105dc962fc88a3ef09515a8a4833a675ba13850701b7e |
|
MD5 | 8c4ca4eb78f9712551948c179d3d88d0 |
|
BLAKE2b-256 | 77664c1af94afb6167b376b294db1c7fc979a021cd7495e354f57e97232f205d |
File details
Details for the file dict_tiny-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: dict_tiny-0.3.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8b44613f545cadeca0fbf20ade0ec8eb057568571d861a395531cdf2a8c7d62 |
|
MD5 | c02f1a252b3b40d67e7e3f63eea173ef |
|
BLAKE2b-256 | 2f1ec438097f7cb398d89e4fa23f95320c9dce602a5a51b6b6de19cdf01f5c1e |