dict-tiny


Namedict-tiny JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/louieh/dict-tiny
SummaryA command line translator that integrates with Google Translate and Youdao Dict. Just for fun :)
upload_time2023-12-20 15:06:15
maintainer
docs_urlNone
authorlouie
requires_python>=3.0
license
keywords python youdao dictionary command-line plumbum translator translate google-translation-api deepl deepl-translation-api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dict-tiny

[![PyPI version](https://img.shields.io/pypi/v/dict-tiny.svg)](https://pypi.python.org/pypi/dict-tiny/) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/louieh/dict-tiny/Upload%20Dict-tiny%20Python%20Package)](https://github.com/louieh/dict-tiny/actions?query=workflow%3A%22Upload+Dict-tiny+Python+Package%22) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Downloads](https://pepy.tech/badge/dict-tiny)](https://pepy.tech/project/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)

```shell
$ pip install dict-tiny
```



## Upgrading

```shell
$ pip install --upgrade dict-tiny
```



## Usage

### Youdao Dict

```python
$ dict-tiny book
>>> Youdao Dict <<<
book  英[bʊk]美[bʊk]
===================
n. 书籍;卷;账簿;名册;工作簿
vt. 预订;登记
n. (Book)人名;(中)卜(广东话·威妥玛);(朝)北;(英)布
```

```python
$ dict-tiny 书
>>> Youdao Dict <<<
书  [shū]
=========
n.book;letter;script
vt.write
```

Use `-m`/`--more` to get more detail translation for word:

```python
$ 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.
  她曾经参加过石油大会战。
```

```python
$ 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:

```python
$ dict-tiny -g book
>>> Google Translate <<<
detected language: en
input: book
output: 书
```

Add `--target-language` to specify what language you want to translate into:

```python
$ 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:

```python
$ 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](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) codes. 

  ```python
  $ 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:

  ```python
  $ 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 the `target language` you prefer so that you do not have to specify the `target language` every time. `Dict-tiny` will first get `target 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 are `ENGLISH_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:


```python
$ dict-tiny -c -y
>>> Youdao Dict <<<
encounter  英[ɪnˈkaʊntə(r)]美[ɪnˈkaʊntər]
=========================================
v. 遭遇;偶遇,邂逅
n. 偶遇,邂逅;经历,体验;冲突;比赛,交锋
```

```python
$ 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

[MIT](https://github.com/louieh/dict-tiny/blob/master/LICENSE)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/louieh/dict-tiny",
    "name": "dict-tiny",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "python youdao dictionary command-line plumbum translator translate google-translation-api deepl deepl-translation-api",
    "author": "louie",
    "author_email": "louiehan1015@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/40/9f/b3894a0e602f81cfbe62e8589c383224a2a3faf94e7b4ef90cd0914e0059/dict-tiny-1.2.1.tar.gz",
    "platform": null,
    "description": "# Dict-tiny\n\n[![PyPI version](https://img.shields.io/pypi/v/dict-tiny.svg)](https://pypi.python.org/pypi/dict-tiny/) [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/louieh/dict-tiny/Upload%20Dict-tiny%20Python%20Package)](https://github.com/louieh/dict-tiny/actions?query=workflow%3A%22Upload+Dict-tiny+Python+Package%22) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Downloads](https://pepy.tech/badge/dict-tiny)](https://pepy.tech/project/dict-tiny)\n\n\nA command line translator that integrates with Google Translate, ~~DeepL Translator~~ and Youdao Dict\n\nJust for fun :)\n\n\n\n## Installation\n\nYou can install `dict-tiny` via pip. (Python 3 only)\n\n```shell\n$ pip install dict-tiny\n```\n\n\n\n## Upgrading\n\n```shell\n$ pip install --upgrade dict-tiny\n```\n\n\n\n## Usage\n\n### Youdao Dict\n\n```python\n$ dict-tiny book\n>>> Youdao Dict <<<\nbook  \u82f1[b\u028ak]\u7f8e[b\u028ak]\n===================\nn. \u4e66\u7c4d\uff1b\u5377\uff1b\u8d26\u7c3f\uff1b\u540d\u518c\uff1b\u5de5\u4f5c\u7c3f\nvt. \u9884\u8ba2\uff1b\u767b\u8bb0\nn. (Book)\u4eba\u540d\uff1b(\u4e2d)\u535c(\u5e7f\u4e1c\u8bdd\u00b7\u5a01\u59a5\u739b)\uff1b(\u671d)\u5317\uff1b(\u82f1)\u5e03\n```\n\n```python\n$ dict-tiny \u4e66\n>>> Youdao Dict <<<\n\u4e66  [sh\u016b]\n=========\nn.book;letter;script\nvt.write\n```\n\nUse `-m`/`--more` to get more detail translation for word:\n\n```python\n$ dict-tiny \u66fe\u7ecf -m\n>>> Youdao Dict <<<\n\u66fe\u7ecf  [c\u00e9ng j\u012bng]\n=================\nadv.once;ever\n\nmore detail:\n======== \u526f\u8bcd ========\n1:\n  \uff08\u8868\u793a\u6709\u8fc7\u67d0\u4e9b\u884c\u4e3a\u6216\u60c5\u51b5\uff09 once:\n  He once lived in Shanghai.\n  \u4ed6\u66fe\u7ecf\u5728\u4e0a\u6d77\u4f4f\u8fc7\u3002\n  She has taken part in a major battle for oil.\n  \u5979\u66fe\u7ecf\u53c2\u52a0\u8fc7\u77f3\u6cb9\u5927\u4f1a\u6218\u3002\n```\n\n```python\n$ dict-tiny dictionary -m\n>>> Youdao Dict <<<\ndictionary  \u82f1['d\u026ak\u0283(\u0259)n(\u0259)r\u026a]\u7f8e['d\u026ak\u0283\u0259'n\u025bri]\n=============================================\nn. \u5b57\u5178\uff1b\u8bcd\u5178\n\nmore detail (collins):\n======== N-COUNT \u53ef\u6570\u540d\u8bcd ========\n \u00b7 \u8bcd\u5178\n\nA 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.\n\n\n \u4f8b: ...a Spanish-English dictionary.\n     \u2026\u4e00\u672c\u897f\u73ed\u7259\u8bed\u2014\u82f1\u8bed\u8bcd\u5178\u3002\n```\n\n**Note:**\n\n* Some words have a lot of translation that may occupy the entire screen.\n* Only supports English or Chinese words currently.\n\n### Google Translate\n\nAdd `-g` / `--google` to use Google Translate:\n\n```python\n$ dict-tiny -g book\n>>> Google Translate <<<\ndetected language: en\ninput: book\noutput: \u4e66\n```\n\nAdd `--target-language` to specify what language you want to translate into\uff1a\n\n```python\n$ dict-tiny -g book --target-language japanese\n>>> Google Translate <<<\ndetected language: en\ninput: book\noutput: \u672c\n```\n\nAdd `--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.\n\nSo, of course, you can use it to detect the language type:\n\n```python\n$ dict-tiny --detect-language book\n>>> Google Translate <<<\nconfidence: 1\ninput: book\nlanguage: en\nname: English\n```\n\n**Note:**\n\n* Make sure the google service is available in your network environment.\n\n* The source and target languages for Google Translate are identified using the [iso-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) codes. \n\n  ```python\n  $ dict-tiny -g book --target-language zh --source-language en\n  >>> Google Translate <<<\n  input: book\n  output: \u4e66\n  source language: en\n  ```\n\n  You can also enter the ISO language name:\n\n  ```python\n  $ dict-tiny -g book --target-language German --source-language English\n  >>> Google Translate <<<\n  input: book\n  output: Buchen\n  source language: English\n  ```\n\n### Target language\n\n* Setting the environment variable `$DICT_TINY_TARGET_LAN` to the `target language` you prefer so that you do not have to specify the `target language` every time. `Dict-tiny` will first get `target language` from `$DICT_TINY_TARGET_LAN`. Giving the `--target-language` switch on the command line will override the environment variable value.\n* The default `target-language` for Goole Translate are `ENGLISH_ISO_639='en'`  if the content you input is not in English.\n\n### ~~DeepL Translate~~\n\nFor some reason I am no longer allowed to use deepl pro, so deepl is no longer supported.\n\n### Default behavior\n\n* Youdao Dict is the default translator, which means Youdao Dict will be used when no translator is specified.\n* If the target language is not specified, Chinese or English will be set as the default target language.\n\n### Use clipboard content\n\nUse `-c`/`--clipboard` to use the contents of the clipboard:\n\n\n```python\n$ dict-tiny -c -y\n>>> Youdao Dict <<<\nencounter  \u82f1[\u026an\u02c8ka\u028ant\u0259(r)]\u7f8e[\u026an\u02c8ka\u028ant\u0259r]\n=========================================\nv. \u906d\u9047\uff1b\u5076\u9047\uff0c\u9082\u9005\nn. \u5076\u9047\uff0c\u9082\u9005\uff1b\u7ecf\u5386\uff0c\u4f53\u9a8c\uff1b\u51b2\u7a81\uff1b\u6bd4\u8d5b\uff0c\u4ea4\u950b\n```\n\n```python\n$ dict-tiny -g -c\n>>> Google Translate <<<\ninput: clipboard\noutput: \u526a\u8d34\u677f\ndetected language: en\n```\n\n**Note:**\n\n* `-c`/`--clipboard` has low priority. If you add `-c` and a word at the same time, the switch `-c` will be ignored.\n\n\n\n\n## License\n\n[MIT](https://github.com/louieh/dict-tiny/blob/master/LICENSE)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A command line translator that integrates with Google Translate and Youdao Dict. Just for fun :)",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/louieh/dict-tiny"
    },
    "split_keywords": [
        "python",
        "youdao",
        "dictionary",
        "command-line",
        "plumbum",
        "translator",
        "translate",
        "google-translation-api",
        "deepl",
        "deepl-translation-api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3be76ccf22479bda5cdb79b0ee14973d359946c61e9b26c4c6e75c6f233f52b",
                "md5": "8e2c2b6a8f38bd2823fcea4b763289d9",
                "sha256": "527148940d998856b22fc5cf61faceffc346378e73cc2b35f4a51af6231ad364"
            },
            "downloads": -1,
            "filename": "dict_tiny-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e2c2b6a8f38bd2823fcea4b763289d9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 15723,
            "upload_time": "2023-12-20T15:06:14",
            "upload_time_iso_8601": "2023-12-20T15:06:14.678208Z",
            "url": "https://files.pythonhosted.org/packages/f3/be/76ccf22479bda5cdb79b0ee14973d359946c61e9b26c4c6e75c6f233f52b/dict_tiny-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "409fb3894a0e602f81cfbe62e8589c383224a2a3faf94e7b4ef90cd0914e0059",
                "md5": "bad7a9e73e25fbeba4d1ff30e78760b7",
                "sha256": "c14feaea731b99fe1155bb48902b656ea4397ac7ab007a6a15e2c5aaefd09f2e"
            },
            "downloads": -1,
            "filename": "dict-tiny-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bad7a9e73e25fbeba4d1ff30e78760b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 13290,
            "upload_time": "2023-12-20T15:06:15",
            "upload_time_iso_8601": "2023-12-20T15:06:15.932054Z",
            "url": "https://files.pythonhosted.org/packages/40/9f/b3894a0e602f81cfbe62e8589c383224a2a3faf94e7b4ef90cd0914e0059/dict-tiny-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-20 15:06:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "louieh",
    "github_project": "dict-tiny",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dict-tiny"
}
        
Elapsed time: 0.20728s