M
mf
I'm translating a db from english to spanish with the Google
translator API. The problem is when a TranslationError occurs(usually
because of connection problems). I can
except the first one, but I don't know how to except again. I "solved"
the problem by saving temp db's and then joining them, but it must be
a pythonic way to do it.
Here's a snippet from the code:
english_field = oldDb.fieldData[0] #oldDb is a db filled
with english words
try:
spanish_field = translate(english_field, lang_to='es',
lang_from='en')
except TranslationError:
spanish_field = translate(english_field, lang_to='es',
lang_from='en')
#Then I save the fields into a new db
translator API. The problem is when a TranslationError occurs(usually
because of connection problems). I can
except the first one, but I don't know how to except again. I "solved"
the problem by saving temp db's and then joining them, but it must be
a pythonic way to do it.
Here's a snippet from the code:
english_field = oldDb.fieldData[0] #oldDb is a db filled
with english words
try:
spanish_field = translate(english_field, lang_to='es',
lang_from='en')
except TranslationError:
spanish_field = translate(english_field, lang_to='es',
lang_from='en')
#Then I save the fields into a new db