Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed qcri and yandex #145

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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