【问题标题】:Right-click to translate (look up) with DeepL translator on MacOS右键单击以在 MacOS 上使用 DeepL 翻译器进行翻译(查找)
【发布时间】:2020-01-22 16:30:00
【问题描述】:

有一篇来自 Lukasz Dorosz 的文章 (https://medium.com/@mrdoro/fast-translation-with-google-translator-and-mac-osx-817e32233b7a) 关于使用 Apple Automator 将 Google 翻译器与 macOS 集成。我做到了,它有效。我的问题是 - 如何将 DeepL 翻译器与 macOS 集成?

使用 Automator,您可以通过几个步骤将 Goole Translator 与 macOS 集成:

打开 Automator 并创建一个新服务。 顶部这样设置: 从左栏中,您需要找到并获取两个函数:运行 >Apple 脚本和网站弹出窗口。 将此代码复制并粘贴到 Apple 脚本窗口中。

on run {input, parameters}
    set output to "http://translate.google.com/translate_t?sl=auto&tl=ru&text=" & urldecode(input as string)
    return output
end run
on urldecode(x)
    set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp)'"
    do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode

如何更改脚本以使用来自 DeepL 而不是 Google 的翻译器?

【问题讨论】:

标签: macos google-translate automator deepl


【解决方案1】:

您可以通过单击分享按钮查看 DeepL 链接格式。链接如下所示:

https://www.deepl.com/translator#de/en/Dies%20ist%20kein%20Haus.

所以你的脚本应该是这样的:

on run {input, parameters}
    set output to "https://www.deepl.com/translator#de/en/" & urldecode(input as string)
    return output
end run
on urldecode(x)
    set cmd to "'require \"cgi\"; puts CGI.escape(STDIN.read.chomp)'"
    do shell script "echo " & quoted form of x & " | ruby -e " & cmd
end urldecode

如果文本足够长,链接中的源语言也应该无关紧要,因为 DeepL 语言识别器会确定实际语言。

@tecmec 在他的评论中推荐的 DeepL 应用程序可能比任何脚本都要好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-06
    • 2014-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    相关资源
    最近更新 更多