Merge branch 'master' of github.com:nidhaloff/deep-translator
Browse files- deep_translator/constants.py +25 -25
- deep_translator/linguee.py +1 -1
- docs/README.rst +2 -5
- examples/linguee.py +1 -1
- tests/test_linguee.py +6 -4
deep_translator/constants.py
CHANGED
@@ -180,33 +180,33 @@ PONS_CODES_TO_LANGUAGES = {
|
|
180 |
}
|
181 |
|
182 |
LINGUEE_LANGUAGES_TO_CODES = {
|
183 |
-
"maltese": "
|
184 |
-
"english": "
|
185 |
-
"german": "
|
186 |
-
"bulgarian": "
|
187 |
-
"polish": "
|
188 |
-
"portuguese": "
|
189 |
-
"hungarian": "
|
190 |
-
"romanian": "
|
191 |
-
"russian": "
|
192 |
# "serbian": "sr",
|
193 |
-
"dutch": "
|
194 |
-
"slovakian": "
|
195 |
-
"greek": "
|
196 |
-
"slovenian": "
|
197 |
-
"danish": "
|
198 |
-
"italian": "
|
199 |
-
"spanish": "
|
200 |
-
"finnish": "
|
201 |
-
"chinese": "
|
202 |
-
"french": "
|
203 |
# "croatian": "hr",
|
204 |
-
"czech": "
|
205 |
-
"laotian": "
|
206 |
-
"swedish": "
|
207 |
-
"latvian": "
|
208 |
-
"estonian": "
|
209 |
-
"japanese": "
|
210 |
}
|
211 |
|
212 |
DEEPL_LANGUAGE_TO_CODE = {
|
|
|
180 |
}
|
181 |
|
182 |
LINGUEE_LANGUAGES_TO_CODES = {
|
183 |
+
"maltese": "maltese",
|
184 |
+
"english": "english",
|
185 |
+
"german": "german",
|
186 |
+
"bulgarian": "bulgarian",
|
187 |
+
"polish": "polish",
|
188 |
+
"portuguese": "portuguese",
|
189 |
+
"hungarian": "hungarian",
|
190 |
+
"romanian": "romanian",
|
191 |
+
"russian": "russian",
|
192 |
# "serbian": "sr",
|
193 |
+
"dutch": "dutch",
|
194 |
+
"slovakian": "slovakian",
|
195 |
+
"greek": "greek",
|
196 |
+
"slovenian": "slovenian",
|
197 |
+
"danish": "danish",
|
198 |
+
"italian": "italian",
|
199 |
+
"spanish": "spanish",
|
200 |
+
"finnish": "finnish",
|
201 |
+
"chinese": "chinese",
|
202 |
+
"french": "french",
|
203 |
# "croatian": "hr",
|
204 |
+
"czech": "czech",
|
205 |
+
"laotian": "laotian",
|
206 |
+
"swedish": "swedish",
|
207 |
+
"latvian": "latvian",
|
208 |
+
"estonian": "estonian",
|
209 |
+
"japanese": "japanese",
|
210 |
}
|
211 |
|
212 |
DEEPL_LANGUAGE_TO_CODE = {
|
deep_translator/linguee.py
CHANGED
@@ -62,7 +62,7 @@ class LingueeTranslator(BaseTranslator):
|
|
62 |
if is_input_valid(word, max_chars=50):
|
63 |
# %s-%s/translation/%s.html
|
64 |
url = (
|
65 |
-
f"{self._base_url}{self._source}-{self._target}/
|
66 |
)
|
67 |
url = requote_uri(url)
|
68 |
response = requests.get(url, proxies=self.proxies)
|
|
|
62 |
if is_input_valid(word, max_chars=50):
|
63 |
# %s-%s/translation/%s.html
|
64 |
url = (
|
65 |
+
f"{self._base_url}{self._source}-{self._target}/search/?source={self._source}&query={word}"
|
66 |
)
|
67 |
url = requote_uri(url)
|
68 |
response = requests.get(url, proxies=self.proxies)
|
docs/README.rst
CHANGED
@@ -407,9 +407,6 @@ Linguee Translator
|
|
407 |
|
408 |
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
409 |
|
410 |
-
# pass language by their abbreviation
|
411 |
-
translated_word = LingueeTranslator(source='en', target='fr').translate(word)
|
412 |
-
|
413 |
- Return all synonyms or words that match
|
414 |
|
415 |
.. code-block:: python
|
@@ -656,7 +653,7 @@ Finally, to retrieve a list of available languages for a given translator:
|
|
656 |
Tests
|
657 |
======
|
658 |
|
659 |
-
Developers can install the development version of deep-translator and execute unit tests to verify functionality. For more information on doing this, see `the contribution guidelines <https://deep-translator.readthedocs.io/en/latest/contributing.html
|
660 |
|
661 |
========
|
662 |
Links
|
@@ -688,7 +685,7 @@ Next Steps
|
|
688 |
|
689 |
Take a look in the examples folder for more :)
|
690 |
Contributions are always welcome.
|
691 |
-
Read the Contribution guidelines `Here <https://deep-translator.readthedocs.io/en/latest/contributing.html
|
692 |
|
693 |
==========
|
694 |
Credits
|
|
|
407 |
|
408 |
translated_word = LingueeTranslator(source='english', target='french').translate(word)
|
409 |
|
|
|
|
|
|
|
410 |
- Return all synonyms or words that match
|
411 |
|
412 |
.. code-block:: python
|
|
|
653 |
Tests
|
654 |
======
|
655 |
|
656 |
+
Developers can install the development version of deep-translator and execute unit tests to verify functionality. For more information on doing this, see `the contribution guidelines <https://deep-translator.readthedocs.io/en/latest/contributing.html#get-started>`_
|
657 |
|
658 |
========
|
659 |
Links
|
|
|
685 |
|
686 |
Take a look in the examples folder for more :)
|
687 |
Contributions are always welcome.
|
688 |
+
Read the Contribution guidelines `Here <https://deep-translator.readthedocs.io/en/latest/contributing.html#get-started>`_
|
689 |
|
690 |
==========
|
691 |
Credits
|
examples/linguee.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from deep_translator import LingueeTranslator
|
2 |
|
3 |
-
res = LingueeTranslator(source="
|
4 |
|
5 |
print(res)
|
|
|
1 |
from deep_translator import LingueeTranslator
|
2 |
|
3 |
+
res = LingueeTranslator(source="german", target="english").translate("laufen", return_all=False)
|
4 |
|
5 |
print(res)
|
tests/test_linguee.py
CHANGED
@@ -29,10 +29,12 @@ def test_inputs():
|
|
29 |
with pytest.raises(exceptions.InvalidSourceOrTargetLanguage):
|
30 |
LingueeTranslator(source="", target="en")
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
|
38 |
def test_payload(linguee):
|
|
|
29 |
with pytest.raises(exceptions.InvalidSourceOrTargetLanguage):
|
30 |
LingueeTranslator(source="", target="en")
|
31 |
|
32 |
+
with pytest.raises(exceptions.LanguageNotSupportedException):
|
33 |
+
LingueeTranslator(source="en", target="fr")
|
34 |
+
|
35 |
+
l = LingueeTranslator("english", "french")
|
36 |
+
assert l._source == "english"
|
37 |
+
assert l._target == "french"
|
38 |
|
39 |
|
40 |
def test_payload(linguee):
|