Skip to content

Commit

Permalink
Merge pull request #145 from nidhaloff/hotfix/qcri-yandex
Browse files Browse the repository at this point in the history
fixed qcri and yandex
  • Loading branch information
nidhaloff authored Mar 31, 2022
2 parents aa9b475 + f651d07 commit c42ab79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions deep_translator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
"""
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deep_translator/qcri.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c42ab79

Please sign in to comment.