Merge branch 'master' of https://github.com/nidhaloff/deep-translator into dev
Browse files- .scrutinizer.yml +11 -0
- README.rst +48 -6
- deep_translator/__init__.py +1 -1
- deep_translator/google_trans.py +0 -4
- deep_translator/parent.py +4 -1
- setup.cfg +1 -1
- setup.py +1 -1
.scrutinizer.yml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
checks:
|
2 |
+
python:
|
3 |
+
code_rating: true
|
4 |
+
duplicate_code: true
|
5 |
+
|
6 |
+
build:
|
7 |
+
nodes:
|
8 |
+
analysis:
|
9 |
+
tests:
|
10 |
+
override:
|
11 |
+
- py-scrutinizer-run
|
README.rst
CHANGED
@@ -13,17 +13,23 @@ deep_translator
|
|
13 |
.. image:: https://img.shields.io/pypi/l/deep-translator
|
14 |
:target: https://pypi.python.org/pypi/deep_translator
|
15 |
|
16 |
-
.. image:: https://img.shields.io/pypi/dm/deep-translator
|
17 |
-
:target: https://pypi.python.org/pypi/deep_translator
|
18 |
.. image:: https://img.shields.io/pypi/status/deep-translator
|
19 |
:target: https://pypi.python.org/pypi/deep_translator
|
20 |
-
.. image:: https://img.shields.io/pypi/wheel/deep-translator
|
21 |
-
:target: https://pypi.python.org/pypi/deep_translator
|
22 |
|
23 |
-
.. image:: https://
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
:alt: GitHub last commit
|
25 |
:target: https://pypi.python.org/pypi/deep_translator
|
26 |
|
|
|
|
|
|
|
27 |
.. image:: https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FNidhalBaccouri
|
28 |
:alt: Twitter URL
|
29 |
:target: https://twitter.com/NidhalBaccouri
|
@@ -31,7 +37,6 @@ deep_translator
|
|
31 |
.. image:: https://img.shields.io/badge/$-buy%20me%20a%20coffee-ff69b4.svg?style=social
|
32 |
:target: https://www.buymeacoffee.com/nidhaloff?new=1
|
33 |
|
34 |
-
|
35 |
=======================
|
36 |
Translation for humans
|
37 |
=======================
|
@@ -359,6 +364,43 @@ Side Hint
|
|
359 |
Generally, I find the google and mymemory translators suitable for translating texts/paragraphs, whereas
|
360 |
the pons and linguee translators are good choices if you want to translate words.
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
========
|
363 |
Links
|
364 |
========
|
|
|
13 |
.. image:: https://img.shields.io/pypi/l/deep-translator
|
14 |
:target: https://pypi.python.org/pypi/deep_translator
|
15 |
|
|
|
|
|
16 |
.. image:: https://img.shields.io/pypi/status/deep-translator
|
17 |
:target: https://pypi.python.org/pypi/deep_translator
|
|
|
|
|
18 |
|
19 |
+
.. image:: https://pepy.tech/badge/deep-translator
|
20 |
+
:target: https://pepy.tech/project/deep-translator
|
21 |
+
|
22 |
+
.. image:: https://pepy.tech/badge/deep-translator/month
|
23 |
+
:target: https://pepy.tech/project/deep-translator/month
|
24 |
+
|
25 |
+
|
26 |
+
.. image:: https://img.shields.io/github/last-commit/nidhaloff/deep_translator
|
27 |
:alt: GitHub last commit
|
28 |
:target: https://pypi.python.org/pypi/deep_translator
|
29 |
|
30 |
+
.. image:: https://img.shields.io/pypi/wheel/deep-translator
|
31 |
+
:target: https://pypi.python.org/pypi/deep_translator
|
32 |
+
|
33 |
.. image:: https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FNidhalBaccouri
|
34 |
:alt: Twitter URL
|
35 |
:target: https://twitter.com/NidhalBaccouri
|
|
|
37 |
.. image:: https://img.shields.io/badge/$-buy%20me%20a%20coffee-ff69b4.svg?style=social
|
38 |
:target: https://www.buymeacoffee.com/nidhaloff?new=1
|
39 |
|
|
|
40 |
=======================
|
41 |
Translation for humans
|
42 |
=======================
|
|
|
364 |
Generally, I find the google and mymemory translators suitable for translating texts/paragraphs, whereas
|
365 |
the pons and linguee translators are good choices if you want to translate words.
|
366 |
|
367 |
+
======
|
368 |
+
Tests
|
369 |
+
======
|
370 |
+
|
371 |
+
- Install dev requirements
|
372 |
+
|
373 |
+
.. code-block:: console
|
374 |
+
|
375 |
+
$ pip install -r requirements_dev.txt
|
376 |
+
|
377 |
+
- Or just install pytest
|
378 |
+
|
379 |
+
.. code-block:: console
|
380 |
+
|
381 |
+
$ pip install pytest
|
382 |
+
|
383 |
+
|
384 |
+
- you can run tests individually for each translator by passing the prefix **test_** followed by the translator name as an argument to pytest.
|
385 |
+
|
386 |
+
.. code-block:: console
|
387 |
+
|
388 |
+
$ pytest test_google_trans
|
389 |
+
$ pytest test_linguee
|
390 |
+
$ pytest test_mymemory
|
391 |
+
$ pytest test_pons
|
392 |
+
|
393 |
+
- Alternatively, you can run the test suite
|
394 |
+
|
395 |
+
.. code-block:: console
|
396 |
+
|
397 |
+
$ pytest -ra
|
398 |
+
|
399 |
+
|
400 |
+
|
401 |
+
|
402 |
+
|
403 |
+
|
404 |
========
|
405 |
Links
|
406 |
========
|
deep_translator/__init__.py
CHANGED
@@ -9,7 +9,7 @@ from .detection import single_detection, batch_detection
|
|
9 |
|
10 |
__author__ = """Nidhal Baccouri"""
|
11 |
__email__ = '[email protected]'
|
12 |
-
__version__ = '1.
|
13 |
|
14 |
__all__ = [GoogleTranslator,
|
15 |
PonsTranslator,
|
|
|
9 |
|
10 |
__author__ = """Nidhal Baccouri"""
|
11 |
__email__ = '[email protected]'
|
12 |
+
__version__ = '1.2.0'
|
13 |
|
14 |
__all__ = [GoogleTranslator,
|
15 |
PonsTranslator,
|
deep_translator/google_trans.py
CHANGED
@@ -136,7 +136,3 @@ class GoogleTranslator(BaseTranslator):
|
|
136 |
except Exception as e:
|
137 |
raise e
|
138 |
|
139 |
-
|
140 |
-
if __name__ == '__main__':
|
141 |
-
res = GoogleTranslator("auto", "de").translate("keep it up, you are awesome")
|
142 |
-
print(res)
|
|
|
136 |
except Exception as e:
|
137 |
raise e
|
138 |
|
|
|
|
|
|
|
|
deep_translator/parent.py
CHANGED
@@ -27,7 +27,8 @@ class BaseTranslator(ABC):
|
|
27 |
self._element_tag = element_tag
|
28 |
self._element_query = element_query
|
29 |
self.payload_key = payload_key
|
30 |
-
self.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8)
|
|
|
31 |
'(KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19'}
|
32 |
super(BaseTranslator, self).__init__()
|
33 |
|
@@ -66,3 +67,5 @@ class BaseTranslator(ABC):
|
|
66 |
"""
|
67 |
return NotImplemented('You need to implement the translate method!')
|
68 |
|
|
|
|
|
|
27 |
self._element_tag = element_tag
|
28 |
self._element_query = element_query
|
29 |
self.payload_key = payload_key
|
30 |
+
self.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) '
|
31 |
+
'AppleWebit/535.19'
|
32 |
'(KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19'}
|
33 |
super(BaseTranslator, self).__init__()
|
34 |
|
|
|
67 |
"""
|
68 |
return NotImplemented('You need to implement the translate method!')
|
69 |
|
70 |
+
|
71 |
+
|
setup.cfg
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
[bumpversion]
|
2 |
-
current_version = 1.
|
3 |
commit = True
|
4 |
tag = True
|
5 |
|
|
|
1 |
[bumpversion]
|
2 |
+
current_version = 1.2.0
|
3 |
commit = True
|
4 |
tag = True
|
5 |
|
setup.py
CHANGED
@@ -51,6 +51,6 @@ setup(
|
|
51 |
test_suite='tests',
|
52 |
tests_require=test_requirements,
|
53 |
url='https://github.com/nidhaloff/deep_translator',
|
54 |
-
version='1.
|
55 |
zip_safe=False,
|
56 |
)
|
|
|
51 |
test_suite='tests',
|
52 |
tests_require=test_requirements,
|
53 |
url='https://github.com/nidhaloff/deep_translator',
|
54 |
+
version='1.2.0',
|
55 |
zip_safe=False,
|
56 |
)
|