Skip to content

Commit 1545a49

Browse files
committed
Initial commit
0 parents  commit 1545a49

13 files changed

+968
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

HISTORY.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## v0.1.0
4+
5+
* First release

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2021 Giovanni Salinas
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.md LICENSE
2+
recursive-include tests *.py

README.md

+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
<img src="https://raw.githubusercontent.com/GBS3/pystone/main/media/pystone.png" align="right" width="125">
2+
3+
# pystone
4+
5+
![PyPI Version](https://img.shields.io/pypi/v/pystone?style=flat-square) ![Python Version](https://img.shields.io/pypi/pyversions/pystone?style=flat-square) ![License](https://img.shields.io/pypi/l/pystone?style=flat-square)
6+
7+
A command line tool written in Python for translating text through Reverso.
8+
9+
10+
## Requirements
11+
12+
To be able to use `pystone`, you will need at least Python 3.6 or higher. This tool makes use of the [requests](https://github.com/psf/requests) and [playsound](https://github.com/TaylorSMarks/playsound) packages.
13+
14+
15+
## Installation
16+
17+
To install `pystone`, run the following in your terminal:
18+
19+
```
20+
$ pip install pystone
21+
```
22+
23+
## Usage
24+
25+
In order to use `pystone`, simply type and enter it in your terminal:
26+
27+
```
28+
$ pystone
29+
```
30+
31+
This will activate a command line interpreter that mimics a *session* and allows for quick <kbd>tab</kbd> completions, which in turn optimizes ease of use. It will remember your current source and target languages and will allow you to modify them within the same session. If you want to translate a piece of text into a variety of languages, you can do that without having to repeatedly enter the same text and/or command line arguments.
32+
33+
### Command Line Arguments
34+
35+
On that note, I should explain that there are command line arguments that you *can* use but they're completely optional.
36+
37+
Here they are:
38+
39+
```
40+
Translation options
41+
42+
optional arguments:
43+
-h, --help show this help message and exit
44+
-s LANGUAGE, --source LANGUAGE the source language (default: English)
45+
-t LANGUAGE, --target LANGUAGE the target language
46+
--text TEXT the text to be translated
47+
```
48+
49+
Example:
50+
51+
```
52+
pystone --target Spanish
53+
```
54+
55+
I don't expect these commands to be used very often but they're there in case a user preemptively knows which languages they want to translate between or happens to have a specific text in mind.
56+
57+
### Documented Commands
58+
59+
Once the interpreter has been activated, there are several commands that are at your disposal:
60+
61+
```
62+
Documented commands (type help <topic>):
63+
========================================
64+
alternatives audio deepl examples exit help reverse set settings translate
65+
```
66+
67+
#### settings
68+
69+
`settings` accepts no arguments and outputs your current configuration to the console:
70+
71+
```
72+
Source language: English
73+
Target language: None
74+
Current text: None
75+
Most recent translation: None
76+
```
77+
78+
#### set
79+
80+
`set` accepts at most two space-separated arguments and manages your source and target languages. If only one argument is provided, your target language will be set to that language. If two arguments are provided, both your source language and target language will respectively be set to those languages:
81+
82+
```
83+
(pystone) set Spanish # target language -> Spanish
84+
85+
# ==================
86+
# or
87+
# ==================
88+
89+
(pystone) set German French # source language -> German, target language -> French
90+
```
91+
92+
##### Flexibility
93+
94+
The `set` command is incredibly flexible in that the languages don't need to be specified in English or capitalized and will accept letters with accent marks:
95+
96+
```
97+
(pystone) set Anglais español
98+
```
99+
100+
It will even attempt to determine the languages if you input short abbreviations (*at least 3 characters are recommended for each language*):
101+
102+
```
103+
(pystone) set fra spa # source language -> French, target language -> Spanish
104+
```
105+
106+
#### translate
107+
108+
`translate` accepts text as input and outputs a translation of the text to your target language:
109+
110+
```
111+
(pystone) translate What time is it?
112+
113+
What time is it?
114+
115+
¿Qué hora es?
116+
```
117+
118+
#### examples
119+
120+
`examples` accepts no arguments and either outputs example sentences using your translation (if there are any available) or outputs nothing:
121+
122+
```
123+
(pystone) examples
124+
125+
¿Qué hora es? - Las dos.
126+
¿Qué hora es? son cinco para las diez.
127+
¿Qué hora es? - Las nueve.
128+
¿Qué hora es? - Las tres y media.
129+
¿Qué hora es? Pulse para actualizarla.
130+
¡Dolokhov! ¿Qué hora es?
131+
¿Qué hora es? -Las cuatro.
132+
¿No tiene reloj? - ¿Qué hora es? ...le lanza un puñetazo contundente.
133+
Discúlpeme. ¿Qué hora es?
134+
¿Qué hora es? eh, creo que es, mediodía.
135+
```
136+
137+
#### alternatives
138+
139+
`alternatives` accepts no arguments and either outputs other translations that could be more accurate (if there are any available) or outputs nothing:
140+
141+
```
142+
(pystone) alternatives
143+
144+
¿Qué hora es ahora?
145+
¿QUÉ TIEMPO ES ESTE?
146+
qué hora es!
147+
la hora que es?
148+
¿qué horas son?
149+
```
150+
151+
#### audio
152+
153+
`audio` accepts no arguments and outputs audio of a text-to-speech voice reader reading your translation:
154+
155+
```
156+
(pystone) audio
157+
158+
# 🎶¿Qué hora es?🎶
159+
```
160+
161+
#### reverse
162+
163+
`reverse` accepts no arguments and swaps the languages for the source language and target language with each other:
164+
165+
```
166+
(pystone) reverse
167+
168+
# source language gets set to target language
169+
# target language gets set to source language
170+
```
171+
172+
#### exit
173+
174+
`exit` accepts no arguments and quits the program.
175+
176+
#### help
177+
178+
`help` accepts at most one argument. If no arguments are provided, the available commands will be printed to the console. If an argument is provided and that argument is the name of a command, a short description of the command will be printed to the console:
179+
180+
```
181+
(pystone) help set
182+
183+
Expects 1 or 2 languages separated by spaces as input.
184+
If one argument is provided, the target language will be
185+
changed to the specified language. If two arguments are provided,
186+
both the source language and the target language will
187+
be changed (in that order).
188+
```
189+
190+
#### deepl
191+
192+
*WARNING: this command is currently in experimental mode and I do **NOT** recommend using it without a VPN or a proxy*. *Once I deem it usable/safe, this warning will be removed but there is still much testing to be done*.
193+
194+
*NOTE: translating **to** English or Portugese is not currently supported.*
195+
196+
`deepl` works like `translate`. It accepts text as input and outputs a translation from DeepL of the text to your target language.
197+
198+
199+
## Supported Languages
200+
201+
A table consisting of the currently supported languages:
202+
203+
| Language | Reverso | DeepL |
204+
| :------: | :-----: | :---: |
205+
| Arabic |||
206+
| Chinese |||
207+
| Dutch |||
208+
| English |||
209+
| French |||
210+
| German |||
211+
| Hebrew |||
212+
| Italian |||
213+
| Japanese |||
214+
| Polish |||
215+
| Portuguese |||
216+
| Romanian |||
217+
| Russian |||
218+
| Spanish |||
219+
| Turkish |||

media/pystone.png

63 KB
Loading

0 commit comments

Comments
 (0)