Giter Site home page Giter Site logo

pombredanne / py-translate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjangsangy/py-translate

0.0 2.0 0.0 3.65 MB

A Translation Tool for Humans

Home Page: http://pythonhosted.org/py-translate/

License: Apache License 2.0

Makefile 13.99% Shell 8.36% Python 77.66%

py-translate's Introduction

py-translate

Documentation github travis pypi Wheel

A Translation Tool for Humans

Translate Lewis Carroll: Alice in Wonderland


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

  • Made for Python 3 but still works on Python 2
  • Fast and easy to install, easy to use
  • Supports translation from any language
  • Highly composable interface, the power of Unix pipes and filters.
  • Simple API and documentation

Installation

From PyPI with pip

$ pip install py-translate

From Source at Github

  • Clone the repository
$ git clone https://github.com/jjangsangy/py-translate.git && cd py-translate
  • Install with setup.py
$ python setup.py install

If all else fails use sudo, but only if you must

$ sudo python setup.py install

Usage

translate [--flags] [source] dest

Arguments

Positional
dest Destination language code
source Source language code
Optional
-h,--help Show this help message and exit
-v, --version Show program’s version number and exit
-l,--list [code] Enumerate the name of country and language code pair.
[Optionally specify output language format]
--translit Print out the transliteration of the text

Examples

Hello World from English to Traditional Chinese

$ translate en zh-TW <<< 'Hello World!'
你好世界!

Hello World

  • 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?

Smart Language Detection

Omitting the source language will try to detect it based on the text content

$ translate fr <<< 'I think therefore I am'
Je pense donc je suis

Romanified Transliteration

$ translate --translit en ko <<< 'Want to fight!'
ssaugo sip-eo!

$ translate --translit en zh-TW <<< 'Kidding, we should be friends'
Kāiwánxiào, wǒmen yīnggāi shì péngyǒu

Redirect from File

$ translate zh-TW < 'alice.txt'

阿麗思道:「你不是說你要告訴你的歷史嗎?告訴我你為甚麼恨—那個—那些—C和D,」
她末了兩個字母輕輕兒地說的,怕回來又得罪了牠。

那老鼠對著阿麗思嘆了一口氣道,「唉﹗我的身世說來可真是又長又苦又委屈呀—」

阿麗思聽了,瞧著那老鼠的尾巴說,「你這尾是曲啊﹗可是為甚麼又叫它苦呢﹗」
她就一頭聽著那老鼠說話,一頭在在心上納悶,所以她聽的那老鼠講的「尾曲」
的歷史是差不多像這個樣了的
....

Chaining together Pipes

# Multiple Chaining
$ echo 'What is love?' | translate en zh-TW | translate zh-TW ko | translate ko fr | translate fr en
What is love?

Be Creative!

# Grocery List
$ cat << BUY | translate ko
Celery
Milk
Eggs
Bread
Cereal
BUY

셀러리
우유
달걀
빵
시리얼

Support

Here’s a list of Python platforms that are officially supported.

  • Python 3.4
  • Python 3.3
  • Python 3.2
  • Python 2.7
  • Python 2.6
  • PyPy 2 (Latest)
  • PyPy 3 (latest)

Documentation

Find the latest documentation http://pythonhosted.org/py-translate/

Contribute

  1. Fork us on Github.

  2. Find a bug? Implemented a new feature? Send a pull request to get it merged and published.

  3. Feel free to send an e-mail to the code maintainer for questions or help regarding the codebase. [email protected]

py-translate's People

Contributors

jjangsangy avatar prmtl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.