Nidhal Baccouri commited on
Commit
0fc118e
·
2 Parent(s): fa90b1d 5eb9128

Merge branch 'master' of github.com:nidhaloff/deep-translator

Browse files
deep_translator/constants.py CHANGED
@@ -180,33 +180,33 @@ PONS_CODES_TO_LANGUAGES = {
180
  }
181
 
182
  LINGUEE_LANGUAGES_TO_CODES = {
183
- "maltese": "mt",
184
- "english": "en",
185
- "german": "de",
186
- "bulgarian": "bg",
187
- "polish": "pl",
188
- "portuguese": "pt",
189
- "hungarian": "hu",
190
- "romanian": "ro",
191
- "russian": "ru",
192
  # "serbian": "sr",
193
- "dutch": "nl",
194
- "slovakian": "sk",
195
- "greek": "el",
196
- "slovenian": "sl",
197
- "danish": "da",
198
- "italian": "it",
199
- "spanish": "es",
200
- "finnish": "fi",
201
- "chinese": "zh",
202
- "french": "fr",
203
  # "croatian": "hr",
204
- "czech": "cs",
205
- "laotian": "lo",
206
- "swedish": "sv",
207
- "latvian": "lv",
208
- "estonian": "et",
209
- "japanese": "ja",
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}/translation/{word}.html"
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="de", target="en").translate("laufen", return_all=False)
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
- l1 = LingueeTranslator("en", "fr")
33
- l2 = LingueeTranslator("english", "french")
34
- assert l1._source == l2._source
35
- assert l1._target == l2._target
 
 
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):