Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
when translation fails #76
Would you please test and document the behavior when translation fails, such as when the language is not supported (distinct from an HTTP error)?
from textblob import TextBlob txt=u' Ꭰ Ꭱ Ꭲ Ꭳ Ꭴ Ꭵ Ꭶ Ꭷ Ꭸ Ꭹ Ꭺ Ꭻ Ꭼ Ꭽ Ꭾ Ꭿ Ꮀ Ꮁ Ꮂ Ꮃ Ꮄ Ꮅ Ꮆ Ꮇ Ꮈ Ꮉ Ꮊ Ꮋ Ꮌ Ꮍ Ꮎ Ꮏ Ꮐ Ꮑ Ꮒ Ꮓ Ꮔ Ꮕ Ꮖ Ꮗ Ꮘ Ꮙ Ꮚ Ꮛ Ꮜ Ꮝ Ꮞ Ꮟ Ꮠ Ꮡ Ꮢ Ꮣ Ꮤ Ꮥ Ꮦ Ꮧ Ꮨ Ꮩ Ꮪ Ꮫ Ꮬ Ꮭ Ꮮ Ꮯ Ꮰ Ꮱ Ꮲ Ꮳ Ꮴ Ꮵ Ꮶ Ꮷ Ꮸ Ꮹ Ꮺ Ꮻ Ꮼ Ꮽ Ꮾ Ꮿ Ᏸ Ᏹ Ᏺ Ᏻ Ᏼ ' bl=TextBlob(txt) bl_en=bl.translate(to='en')
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.
What would be the desired behavior in that case - return None?