azure 翻译_如何使用Blazor和Azure认知服务创建多语言翻译器

azure 翻译

介绍 (Introduction)

In this article, we will create a multilanguage translator using Blazor and the Translate Text Azure Cognitive Service.

在本文中,我们将使用Blazor和Translate Text Azure Cognitive Service创建多语言翻译器。

This translator will be able to translate between all the languages supported by the Translate Text API. Currently, the Translate Text API supports more than 60 languages for translation.

该翻译器将能够在翻译文本API支持的所有语言之间进行翻译。 当前,翻译文本API支持60多种语言的翻译。

The application will accept the text to translate and the target language as the input and returns the translated text and the detected language for the input text as the output.

应用程序将接受要翻译的文本和目标语言作为输入,并返回翻译的文本和输入文本的检测语言作为输出。

Take a look at the output shown below.

看一下下面显示的输出。

先决条件 (Prerequisites)

源代码 (Source Code)

You can get the source code from GitHub.

您可以从GitHub获取源代码。

创建Azure翻译器文本认知服务资源 (Create the Azure Translator Text Cognitive Services resource)

Log in to the Azure portal and search for the cognitive services in the search bar and click on the result. Refer to the image shown below.

登录到Azure门户,然后在搜索栏中搜索认知服务,然后单击结果。 请参考下图。

On the next screen, click on the Add button. It will open the cognitive services marketplace page. Search for the Translator Text in the search bar and click on the search result. It will open the Translator Text API page. Click on the Create button to create a new Translator Text resource. Refer to the image shown below.

在下一个屏幕上,单击Add按钮。 它将打开认知服务市场页面。 在搜索栏中搜索“ Translator Text ,然后单击搜索结果。 它将打开“翻译器文本API”页面。 单击Create按钮以创建新的翻译器文本资源。 请参考下图。

On the Create page, fill in the details as indicated below.

在“ Create页面上,如下所示填写详细信息。

  • Name: Give a unique name for your resource.

    名称:为您的资源指定一个唯一的名称。
  • Subscription: Select the subscription type from the dropdown.

    订阅:从下拉列表中选择订阅类型。
  • Pricing tier: Select the pricing tier as per your choice.

    定价层:根据您的选择选择定价层。
  • Resource group: Select an existing resource group or create a new one.

    资源组:选择一个现有的资源组或创建一个新的资源组。

Click on the Create button. Refer to the image shown below.

单击Create按钮。 请参考下图。

After your resource is successfully deployed, click on the “Go to resource” button. You can see the Key and the endpoint for the newly created Translator Text resource. Refer to the image shown below.

成功部署资源后,单击“转到资源”按钮。 您可以看到新创建的Translator Text资源的Key和端点。 请参考下图。

Make a note of the key, as we will be using this in the latter part of this article to request the translations from the Translator Text API. The values are masked here for privacy.

记下该键,因为我们将在本文的后半部分使用它来请求Translator Text API的翻译。 为了保护隐私,此处将这些值屏蔽。

创建服务器端Blazor应用程序 (Create a Server-Side Blazor Application)

Open Visual Studio 2019 and click on “Create a new project”. Select “Blazor App” and click on the “Next” button. Refer to the image shown below.

打开Visual Studio 2019,然后单击``创建新项目''。 选择“ Blazor App”,然后单击“下一步”按钮。 请参考下图。

On the next window, put the project name as BlazorTranslator and click on the “Create” button. The next window will ask you to select the type of Blazor app. Select Blazor Server App and click on the Create button to create a new server-side Blazor application. Refer to the image shown below.

在下一个窗口中,将项目名称命名为BlazorTranslator ,然后单击“创建”按钮。 下一个窗口将要求您选择Blazor应用程序的类型。 选择Blazor Server App ,然后单击Create按钮创建一个新的服务器端Blazor应用程序。 请参考下图。

创建模型 (Creating the Models)

Right-click on BlazorTranslator project and select Add >

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值