Sunday, 10 February 2019

How to tell googletans to ignore certain parts?

I would like to use googletrans to make use of the Google translate API. However, there are strings where are variable names in it:

User "%(first_name)s %(last_name)s (%(email)s)" has been deleted.

If I use this via googletrans I get

from googletrans import Translator
translator = Translator()
translator.translate(u'User "%(first_name)s %(last_name)s (%(email)s)" has been assigned.', src='en', dest='fr').text

I get the following:

L'utilisateur "% (first_name) s% (last_name) s (% (email) s)" a été affecté.

However, the "%(first_name) s% (last_name)s (%(email)s)" has some strings introduced. Is there a way around this? I've already tried:

u'User "<span class="notranslate">%(first_name)s %(last_name)s (%(email)s)</span>" has been assigned.'



from How to tell googletans to ignore certain parts?

No comments:

Post a Comment