A simple command line utility for translating text using Google Translate.
Project description
py-translate is a CLI Tool for Google Translate written in Python!
- Author:
Sang Han, 2014
- License:
Apache Software License v2
- Version:
0.1.5
The end goal is a simple application for translating text in the terminal. Text can be generated interactively or programmatically in the shell environment. Through command line arguments, file descriptors or pipes generating translated output that can be piped to a file or displayed on the terminal.
Features
Simple command line parsing!
Written in pure Python!
Backwards compatable with Python 2.7
Supports for PyPy as target implementation
Supports all language from Google Translate API
The power of Unix pipes and filters
Native UTF-8 Support
Installation
From PyPI with pip (easy)
$ pip install py-translate
From Source at Github
Clone the repository
$ git clone https://github.com/jjangsangy/py-translate.git
Install with setup.py
$ python setup.py install
Usage
translate [options] [source] dest py-translate is a CLI Tool for Google Translate written in Python optional arguments -h, --help show this help message and exit -l, --lang displays acceptable language codes -V, --version show program's version number and exit
Default will translate from english to target language
$ translate zh-TW <<< "Hello World!" 你好世界!
Examples
Just as easily specify a source language by providing it as first argument
# Translate Hello from French to English $ translate fr en <<< 'Bonjour, comment allez-vous!' Hello, how are you?
Redirect from File
$ translate zh-TW < "alice.txt" 阿麗思道:「你不是說你要告訴你的歷史嗎?告訴我你為甚麼恨—那個—那些—C和D,」 她末了兩個字母輕輕兒地說的,怕回來又得罪了牠。 那老鼠對著阿麗思嘆了一口氣道,「唉﹗我的身世說來可真是又長又苦又委屈呀—」 阿麗思聽了,瞧著那老鼠的尾巴說,「你這尾是曲啊﹗可是為甚麼又叫它苦呢﹗」 她就一頭聽著那老鼠說話,一頭在在心上納悶,所以她聽的那老鼠講的「尾曲」 的歷史是差不多像這個樣了的
Chaining together Pipes
# Translate Telephone! $ echo 'What is love?' | translate zh-TW | translate zh-TW ko | translate ko fr | translate fr en What is love?
Be Creative!
# A "Here-String" Grocery List $ cat <<- GROCERY_LIST | translate ko Celery Milk Eggs Bread Cereal GROCERY_LIST 셀러리 우유 달걀 빵 시리얼
Language Codes
Use the -l, or –langs option to see all the possible language codes.
$ translate --lang
Specify the output format by language code
$ translate --lang zh-TW
Documentation
Documentation is available at https://py-translate.readthedocs.org/
Release History
0.1.5 (2014-07-18)
Language Code Generator Fix
0.1.4 (2014-07-05)
General Bug Fixes
Speed Improvements
Length of multibyte characters correctly represented by spooler
Better support for utf-8.
0.1.3 (2014-4-7)
Implemented language discovery arg
Bug Fixes
0.1.2 (2014-4-4)
Documentation reorganization
Bug Fixes
Fixed unicode encode/decode errors
0.1.1 (2014-4-3)
PyPy-c v2.2 now support
Bug Fixes
Quick fix PyPI distribution (huge package sizes)
MANIFEST.in now does it job
Assorted fixes with methods and scope
0.1.0 (2014-4-2)
GTranslate is taken on PyPI.
Name changed to py-translate
Distributed through PyPI and Wheel
More documentation and autoparsing for module functions
Seperated into logical modules in a package rather than one executable __main__.py
0.0.0 (2014-3-31)
Support for Python 2.7 and 3.x
Sphinx Documentation hosted
Travis CI build passed!
Source released on Github
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
Hashes for py_translate-0.1.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11b1dd8fe3e581021b719aaa0ed373b6a76352c35a1dafb9c03fb995a84ea63 |
|
MD5 | b0ea37bf74344a46142ed0054fe2d6f5 |
|
BLAKE2b-256 | f187b56e461d34fa51942e681ba02e826d6571d37ae2ea42243d619781a33e88 |