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

when translation fails #76

az0 opened this issue Jan 9, 2015 · 3 comments

when translation fails #76

az0 opened this issue Jan 9, 2015 · 3 comments


Copy link

az0 commented Jan 9, 2015

Would you please test and document the behavior when translation fails, such as when the language is not supported (distinct from an HTTP error)?

Example (Cherokee):

from textblob import TextBlob
txt=u'    Ꭰ Ꭱ Ꭲ Ꭳ Ꭴ Ꭵ Ꭶ Ꭷ Ꭸ Ꭹ Ꭺ Ꭻ Ꭼ Ꭽ Ꭾ Ꭿ Ꮀ Ꮁ Ꮂ Ꮃ Ꮄ Ꮅ Ꮆ Ꮇ Ꮈ Ꮉ Ꮊ Ꮋ Ꮌ Ꮍ Ꮎ Ꮏ Ꮐ Ꮑ Ꮒ Ꮓ Ꮔ Ꮕ Ꮖ Ꮗ Ꮘ Ꮙ Ꮚ Ꮛ Ꮜ Ꮝ Ꮞ Ꮟ Ꮠ Ꮡ Ꮢ Ꮣ Ꮤ Ꮥ Ꮦ Ꮧ Ꮨ Ꮩ Ꮪ Ꮫ Ꮬ Ꮭ Ꮮ Ꮯ Ꮰ Ꮱ Ꮲ Ꮳ Ꮴ Ꮵ Ꮶ Ꮷ Ꮸ Ꮹ Ꮺ Ꮻ Ꮼ Ꮽ Ꮾ Ꮿ Ᏸ Ᏹ Ᏺ Ᏻ Ᏼ '
Copy link

sloria commented Jun 10, 2015

TextBlob will return whatever result is returned by the Google Translator. There really currently no way to detect whether language of the source text is unsupported.

@sloria sloria closed this as completed Jun 10, 2015
Copy link

If the translation is unsuccessful, the original string is returned, with whitespace removed:

>>> translator.translate(u'        Ꭰ Ꭱ Ꭲ Ꭳ Ꭴ Ꭵ     ', to_lang='en')

However, the JSON response from the API includes both the original and translated string. If they match, we could infer that the translation was not successful.

         "trans":"Ꭰ Ꭱ Ꭲ Ꭳ Ꭴ Ꭵ",
         "orig":"Ꭰ Ꭱ Ꭲ Ꭳ Ꭴ Ꭵ",

What would be the desired behavior in that case - return None?

Copy link

az0 commented Jun 10, 2015

Yes, either return None or raise an exception.


sloria added a commit that referenced this issue Jul 19, 2015
Fix #76 - when translation fails, raise TranslatorError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

3 participants