nidhal baccouri commited on
Commit
a98dd06
·
1 Parent(s): b3b32a9

refactored ms

Browse files
Files changed (1) hide show
  1. deep_translator/microsoft.py +6 -3
deep_translator/microsoft.py CHANGED
@@ -68,7 +68,7 @@ class MicrosoftTranslator:
68
  def _map_language_to_code(self, language):
69
  """
70
  map the language to its corresponding code (abbreviation) if the language was passed by its full name by the user
71
- @param languages: a string (if 1 lang) or a list (if multiple langs)
72
  @return: mapped value of the language or raise an exception if the language is not supported
73
  """
74
  if type(language) is str:
@@ -84,7 +84,7 @@ class MicrosoftTranslator:
84
  def is_language_supported(self, language):
85
  """
86
  check if the language is supported by the translator
87
- @param languages: a string (if 1 lang) or a list (if multiple langs)
88
  @return: bool or raise an Exception
89
  """
90
  if type(language) is str:
@@ -105,7 +105,10 @@ class MicrosoftTranslator:
105
  # I have not added multiple text processing here since it is covered by the translate_batch method
106
  valid_microsoft_json = [{'text': text}]
107
  try:
108
- requested = requests.post(self.__base_url, params=self.url_params, headers=self.headers, json=valid_microsoft_json)
 
 
 
109
  except requests.exceptions.RequestException:
110
  exc_type, value, traceback = sys.exc_info()
111
  logging.warning(f"Returned error: {exc_type.__name__}")
 
68
  def _map_language_to_code(self, language):
69
  """
70
  map the language to its corresponding code (abbreviation) if the language was passed by its full name by the user
71
+ @param language: a string (if 1 lang) or a list (if multiple langs)
72
  @return: mapped value of the language or raise an exception if the language is not supported
73
  """
74
  if type(language) is str:
 
84
  def is_language_supported(self, language):
85
  """
86
  check if the language is supported by the translator
87
+ @param language: a string (if 1 lang) or a list (if multiple langs)
88
  @return: bool or raise an Exception
89
  """
90
  if type(language) is str:
 
105
  # I have not added multiple text processing here since it is covered by the translate_batch method
106
  valid_microsoft_json = [{'text': text}]
107
  try:
108
+ requested = requests.post(self.__base_url,
109
+ params=self.url_params,
110
+ headers=self.headers,
111
+ json=valid_microsoft_json)
112
  except requests.exceptions.RequestException:
113
  exc_type, value, traceback = sys.exc_info()
114
  logging.warning(f"Returned error: {exc_type.__name__}")