From f651d0771c2a8008d03e2d3830eac88ffab08f49 Mon Sep 17 00:00:00 2001 From: nidhal baccouri Date: Thu, 31 Mar 2022 21:32:11 +0200 Subject: [PATCH] fixed qcri and yandex --- deep_translator/base.py | 18 +++++++++--------- deep_translator/qcri.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/deep_translator/base.py b/deep_translator/base.py index c90c910..6dd7cc1 100644 --- a/deep_translator/base.py +++ b/deep_translator/base.py @@ -28,8 +28,8 @@ def __init__( @param target: target language to translate to """ self._base_url = base_url - self.languages = languages - self.supported_languages = list(self.languages.keys()) + self._languages = languages + self._supported_languages = list(self._languages.keys()) if not source: raise InvalidSourceOrTargetLanguage(source) if not target: @@ -68,16 +68,16 @@ def _map_language_to_code(self, *languages): @return: mapped value of the language or raise an exception if the language is not supported """ for language in languages: - if language in self.languages.values() or language == "auto": + if language in self._languages.values() or language == "auto": yield language - elif language in self.languages.keys(): - yield self.languages[language] + elif language in self._languages.keys(): + yield self._languages[language] else: raise LanguageNotSupportedException( language, message=f"No support for the provided language.\n" f"Please select on of the supported languages:\n" - f"{self.languages}") + f"{self._languages}") def _same_source_target(self) -> bool: return self._source == self._target @@ -90,7 +90,7 @@ def get_supported_languages( @param as_dict: if True, the languages will be returned as a dictionary mapping languages to their abbreviations @return: list or dict """ - return self.supported_languages if not as_dict else self.languages + return self._supported_languages if not as_dict else self._languages def is_language_supported(self, language: str, **kwargs) -> bool: """ @@ -100,8 +100,8 @@ def is_language_supported(self, language: str, **kwargs) -> bool: """ if ( language == "auto" - or language in self.languages.keys() - or language in self.languages.values() + or language in self._languages.keys() + or language in self._languages.values() ): return True else: diff --git a/deep_translator/qcri.py b/deep_translator/qcri.py index 1ac92d4..a882714 100644 --- a/deep_translator/qcri.py +++ b/deep_translator/qcri.py @@ -34,7 +34,7 @@ def __init__( self.params = {"key": self.api_key} super().__init__( - base_url=BASE_URLS.get("QcriTranslator"), + base_url=BASE_URLS.get("QCRI"), source=source, target=target, languages=QCRI_LANGUAGE_TO_CODE,