【发布时间】:2017-05-18 02:59:15
【问题描述】:
在 Python 中使用 Google Translate API,如何指示某些文本不需要翻译?我拥有的文本包括变量名称,例如$name$ 应该保持原样。我试过用引号和尖括号括起来,但到目前为止没有成功。
【问题讨论】:
-
你试过
<span class="notranslate">$name$</span>吗? -
感谢两个回复(并为我的缓慢回复道歉 - 这是一个偶尔的爱好项目),但我使用的是 python API,所以不要认为这些适用。进行翻译的脚本的 sn-p 是: t = service.translations().list(source=base, target=targ, format='text', q=[text]).execute() 其中 text 类似于: 'Here is my $code$ text' 我尝试将 $code$ 位用自己的引号括起来作为 'Here is my "$code" text' 和 'Here is my $code$ text' 但到目前为止还没有任何乐趣。
-
后者是我希望适用的。哦,你试过
service.translations().list(source=base, target=targ, format='html', q='Here is my <span class="notranslate">$code$</span>)吗? (免责声明,我对什么是有效格式一无所知)