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

Translate from same language #9019

Closed
MayuraVerma opened this issue Aug 12, 2019 · 4 comments
Closed

Translate from same language #9019

MayuraVerma opened this issue Aug 12, 2019 · 4 comments
Assignees
Labels
api: translation Issues related to the Cloud Translation API API. backend external This issue is blocked on a bug with the actual product. type: question Request for information or clarification. Not an issue.

Comments

@MayuraVerma
Copy link

It is possible to translate the text from same language, target and destination = same language in the web.

But in Python, it throws an error.

If I download the code, will I be able to turn off the restriction.

Please assist.

@tseaver tseaver added api: translation Issues related to the Cloud Translation API API. type: question Request for information or clarification. Not an issue. labels Aug 13, 2019
@tseaver
Copy link
Contributor

tseaver commented Aug 13, 2019

Can you show a sample of the Python code, and the full traceback?

@MayuraVerma
Copy link
Author

MayuraVerma commented Aug 13, 2019

  1. Python Code: with source language = (blank) 'auto detect'
project_id = <removed>
text = 'Maduve Maadikondu'
location = 'global'

#v3
parent = client.location_path(project_id, location)

response = client.translate_text(
    parent=parent,
    contents=[text],
    mime_type='text/html',  # mime types: text/plain, text/html
#    source_language_code='en',
    target_language_code='kn')
for translation in response.translations:
    print('Translated Text: {}'.format(translation.translated_text))
Output--> Translated Text: Maduve Maadikondu
  1. Python Code:
    source_language_code='kn',

Output--> Failed

six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Target language can't be equal to source language.
  1. Python Code:
    source_language_code='en',

Output--> Translated Text: ಮಧುವೆ ಮಡಿಕಂಡು
This is wrong translation.

  1. From WEB
    Text: Maduve Maadikondu

Expected Result:
This is from the web.
It works both for Source language: 'Detect Language' or Kannada (kn)
image

image

@tseaver tseaver added backend external This issue is blocked on a bug with the actual product. labels Aug 13, 2019
@tseaver
Copy link
Contributor

tseaver commented Aug 13, 2019

@beccasaurus Can you help diagnose why the translate API returns a 400 for source language == target language, whereas the Web UI allows it?

@busunkim96
Copy link
Contributor

busunkim96 commented Aug 16, 2019

@MayuraVerma translate.google.com has features that aren't available via the Translate API. If this is of interest, you can file an issue on the Translation team's public tracker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: translation Issues related to the Cloud Translation API API. backend external This issue is blocked on a bug with the actual product. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants