|
|
Posted onYesterday at 11:58
|
|
|
|

Requirements: Need to call the translation service interface to translate text content in batches, there are only a few well-known manufacturers, such as: Google Translate, Azure Translate, Baidu Translate, DeepL, Aws, etc.
Review:
Common translation service providers
Google Cloud Translation API (Google Translate):The hyperlink login is visible. Microsoft Azure Translator (Azure Cognitive Services):The hyperlink login is visible. DeepL API:The hyperlink login is visible.
Azure Translator
Azure Translator is a cloud-based machine translation service that can be used to translate text and documents through simple REST API calls. The service uses modern neural network machine translation technology. The custom translator interface allows you to create custom neural network translation systems using translation memories. A custom translation system can be used to translate text and documents using Translator.
Documentation:The hyperlink login is visible.
First, open the Azure website to sign in, and then create a Translator resource in Microsoft Foundry. As shown below:
Or just click on the link:The hyperlink login is visible., as shown in the figure below:
Customize the name, select the region Global (please select the "Global" region,Unless the business or application requires a specific region。 Apps that don't offer region selection use the Global region. )。
After the deployment is completed, go to the created resource, as shown in the following figure:
In Resource Management, select the key and endpoint, as shown in the following figure:
View keys and API addresses. Text Translation REST API Documentation Address:The hyperlink login is visible.
Open Postman for testing, fill in the request parameters and other information in the document, and perform the test, as shown in the figure below:
curl command is as follows:
The request limit and concurrency limit are as follows:
There is no limit to concurrent requests, but !! But hewill be averaged to every minute according to your quota!!!
Service Limitations:The hyperlink login is visible.
C# uses HttpClient to call translations
Without using any third-party dependencies, you can call it directly using HttpClient, the code is as follows:
Configure the key in appsettings.json as follows:
Common mistakes:
{"error":{"code":429001,"message":"The server rejected the request because the client has exceeded request limits."}} {"error":{"code":401001,"message":"The request is not authorized because credentials are missing or invalid."}} {"error":{"code":400072,"message":"The array of input text has too many elements."}} {"error":{"code":500000,"message":"An unexpected error occurred. If the error persists, report it with date/time of error, request identifier from response header X-RequestId, and client identifier from request header X-ClientTraceId."}} You can view the supervisors in the background and view the calls of the last hour through the indicators, as shown in the figure below:
(End) |
Previous:Use XPath to retrieve XML, HTML document content
|