当我翻译返回撇号的文本时,我遇到了一个问题
en: "this is me" == fr: "c'est moi"
,但我明白了" c'est moi"
。为此,我想将格式指定为文本,但是当我执行脚本时,我得到:
TypeError: translate() got an unexpected keyword argument 'format'
from google.cloud import translate
# Instantiates a client
translate_client = translate.Client()
# The text to translate
text = u'this is me'
# The target language
target = 'fr'
# Translates some text into Russian
translation = translate_client.translate(
text,
target_language=target, format='text')
print(u'Text: {}'.format(text))
print(u'Translation: {}'.format(translation['translatedText']))