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

[Bug]: translator server - google: language map is empty so getting error "Unsupported from_language[ar] in []" #144

Closed
2 tasks done
SteniMariyaThomas opened this issue Sep 19, 2023 · 24 comments

Comments

@SteniMariyaThomas
Copy link

Debug Tips

  • I'm sure I've read this project's Issues of README.

What happened?

While translating an arabic content to english using translator server: google, I am getting error

Unsupported from_language[ar] in []

On further research I found that language_map is getting as empty.

And urllib.parse.urlparse(r.url).hostname is consent.google.com. Based on that while getting consent cookie input_element is empty input_element = et.xpath('.//input[@type="hidden"][@name="v"]')

It was working previously. Now failing to translate due to this error. I am using latest version of translators

Any help will be greatly appreciated!

APP Version

0.0.1(example)

Python Version

3.9 (Default)

Runtime Environment

Linux CentOS (Default)

Country/Region

Dubai

Relevant log output

No response

Screenshots

![DESCRIPTION](LINK.png)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Cabu
Copy link

Cabu commented Sep 19, 2023

See #142

@UlionTse
Copy link
Owner

@SteniMariyaThomas
Hello friend, please give me more error information! Whether the version is 5.8.3 or not?
translators_20230919

@SteniMariyaThomas
Copy link
Author

@UlionTse Yes the version is 5.8.3. Issue exists in previous version also

@UlionTse
Copy link
Owner

@SteniMariyaThomas Try ts.get_languages('google'). Whether you made a high-frequency request, or first request shows error?

@ManuelSchneid3r
Copy link

>>> import translators as ts
>>> ts.get_languages('google')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 5204, in get_languages
    _ = self._test_translate(_ts=translator)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 5188, in _test_translate
    result = self.translators_dict[_ts](
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 104, in _wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 261, in _wrapper
    return func(*args, **{**kwargs, **{'query_text': query_text}})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 599, in google_api
    from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/translators/server.py", line 174, in check_language
    raise TranslatorError('Unsupported to_language[{}] in {}.'.format(to_language, sorted(language_map.keys())))
translators.server.TranslatorError: Unsupported to_language[en] in [].

@UlionTse
Copy link
Owner

UlionTse commented Sep 27, 2023

@ManuelSchneid3r Bro, you should update version, v5.8.5 shouldn't show errors like yours.

@ManuelSchneid3r
Copy link

>>> ts.__version__
'5.8.5'
>>> ts.get_languages('google')
{'auto': 'en', 'zh-CN': 'en', 'en': 'zh-CN'}

@SteniMariyaThomas
Copy link
Author

@SteniMariyaThomas Hello friend, please give me more error information! Whether the version is 5.8.3 or not? translators_20230919

Its 5.8.3

@UlionTse
Copy link
Owner

@ManuelSchneid3r Why? Which country or region are you in? Is it because Google offers different services in different regions?
translators20230927

@UlionTse
Copy link
Owner

@ManuelSchneid3r Can you send me your host_html about https://translate.google.com, my email is [email protected], thanks.

@SteniMariyaThomas
Copy link
Author

@SteniMariyaThomas Try ts.get_languages('google'). Whether you made a high-frequency request, or first request shows error?

both cases

@UlionTse
Copy link
Owner

@ManuelSchneid3r Why? Which country or region are you in? Is it because Google offers different services in different regions? translators20230927

@SteniMariyaThomas Same question.

@UlionTse
Copy link
Owner

@ManuelSchneid3r Can you send me your host_html about https://translate.google.com, my email is [email protected], thanks.

@SteniMariyaThomas Both helps.

@UlionTse
Copy link
Owner

@SteniMariyaThomas Try ts.get_languages('google'). Whether you made a high-frequency request, or first request shows error?

both cases

@ManuelSchneid3r high-frequency request, and you?

@ManuelSchneid3r
Copy link

Nope, single request from python shell

@ManuelSchneid3r
Copy link

@ManuelSchneid3r Can you send me your host_html about https://translate.google.com, my email is [email protected], thanks.

How can I obtain the host_html? You mean the website source code?

@UlionTse
Copy link
Owner

@ManuelSchneid3r Can you send me your host_html about https://translate.google.com, my email is [email protected], thanks.

How can I obtain the host_html? You mean the website source code?

@ManuelSchneid3r Yeah.

@ManuelSchneid3r
Copy link

@ManuelSchneid3r
Copy link

btw bavaria backend was chosen (germany)

@UlionTse
Copy link
Owner

@ManuelSchneid3r
Thanks for your html, bro.
But look at this, you can get_languages('google').
translators20230930v2

@UlionTse
Copy link
Owner

#142 Same reason?

@ManuelSchneid3r
Copy link

I dont know where the problem stems from, but its still …


>>> import translators as ts
>>> ts.__version__
'5.8.5'
>>> ts.get_languages('google')
{'auto': 'en', 'zh-CN': 'en', 'en': 'zh-CN'}

@UlionTse
Copy link
Owner

UlionTse commented Oct 7, 2023

@ManuelSchneid3r @Cabu Bros, please pip install --upgrade translators==5.8.6.

@ManuelSchneid3r
Copy link

works, ty 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants