【问题标题】:Using Google Translate API in Python, how do you indicate that some text is not to be translated?在 Python 中使用 Google Translate API,如何指示某些文本不需要翻译?
【发布时间】: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>)吗? (免责声明,我对什么是有效格式一无所知)

标签: python translate


【解决方案1】:

我刚刚发现了一些东西:

This contains <span class="notranslate">$code$</span>, which will be skipped.

相关:

【讨论】:

    猜你喜欢
    • 2020-02-11
    • 2017-05-31
    • 2015-07-25
    • 2012-11-18
    • 1970-01-01
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多