如何使用Google Translate API在Microsoft Excel中翻译文本? [英] How can I use Google Translate API to Translate text in Microsoft Excel

查看:1217
本文介绍了如何使用Google Translate API在Microsoft Excel中翻译文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这里有人可以帮助我使用谷歌翻译器API。我有一个约80k行的excel文件,并且我正在尝试构建一个宏,它将第一行以外的列中的所有内容翻译成一行。作为示例,我在Microsoft Excel中有六列,如下面的

Excel列标题




  • 列A =姓名

  • 列B =地址
  • 列C =电话号码

  • 列D =请求

  • E栏=谷歌翻译请求

  • 栏F =注释


,我想使用google翻译器API来获取D列中的内容并将其转换为E列,而无需翻译第一行中的内容,因为这些是我的列标题。这是可能的使用谷歌翻译API在Excel宏中,如果是的话,将如何做到这一点? 解决方案

为了翻译Excel电子表格中的内容,您的选项可以是以下内容之一:


  1. 使用内置的 Microsoft文本翻译

  2. 编写一个与 Microsoft Text Translator API
  3. 编写一个VBA脚本,与 Google翻译API


    根据用例和您的自信程度与微软的翻译功能,我可能会使用内置的解决方案,因为它可能是最简单的路线。根据您使用的Excel版本,它甚至可以内置到菜单中。



    如果不是这样,您可以使用VBA脚本来使用 Microsoft Text Translator REST API ,如@sysmod在先前的回答中所建议的。由于我对该API并不完全熟悉,所以我强烈建议阅读链接的文档。



    如果您更喜欢使用Google翻译API,那么会有一个REST您可以使用上面链接的API。您基本上需要使用VBA脚本来发出 GET POST 请求到

    请记住,就REST API(Microsoft和Google)而言,您需要非常具体的查询参数,如其各自的链接文档中所示, d还需要使用订阅密钥 API密钥对您的项目/应用程序进行身份验证。这是Google的微软跟踪您的应用程序使用了多少免费配额的唯一方式。


    I am hoping someone here can help me with the google translator API. I have an excel file with about 80k rows, and I am trying to build a macro where it translates everything in a column except for the first row. As an example I have six columns in Microsoft Excel such as the below

    Excel Column Headers

    • Column A = Name
    • Column B = Address
    • Column C = Phone Number
    • Column D = Request
    • Column E = Google Translated Request
    • Column F = Notes

    and I want to use the google translator API to take what is in column D and translate it to column E without translating what is in the first row as those are my column titles. Is this possible to do within an Excel Macro using the google translate API, and if so how would one do this?

    解决方案

    In order to translate content from your Excel spreadsheets, your options would be one of the following:

    1. Use built-in Microsoft text translation
    2. Write a VBA script that communicates with the Microsoft Text Translator API
    3. Write a VBA script that communicates with the Google Translation API

    Depending on the use case and how confident you are with Microsoft's translation feature, I'd probably use the built in solution as it would likely be the simplest route. Depending on the version of Excel you have, it could even be built into the menus.

    If not, you could use VBA script to use the Microsoft Text Translator REST API as suggested by @sysmod in a previous answer. As I'm not entirely familiar with that API, I'd strongly recommend reading the linked documentation.

    If you prefer to use the Google Translation API, there is a REST API that you can use as linked above. You'd essentially need to use VBA script to issue a GET or POST request to https://translation.googleapis.com/language/translate/v2.

    Keep in mind that in the case of both REST APIs (Microsoft and Google alike), you would need very specific query parameters as shown in their respective linked documentation and you'd also need to authentication your project/application using a subscription key or API key. This is the only way for Microsoft of Google to keep track of how much free quota your application has used.

    这篇关于如何使用Google Translate API在Microsoft Excel中翻译文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆