CognitiveServices.Translator.Client
1.0.0
See the version list below for details.
dotnet add package CognitiveServices.Translator.Client --version 1.0.0
NuGet\Install-Package CognitiveServices.Translator.Client -Version 1.0.0
<PackageReference Include="CognitiveServices.Translator.Client" Version="1.0.0" />
paket add CognitiveServices.Translator.Client --version 1.0.0
#r "nuget: CognitiveServices.Translator.Client, 1.0.0"
// Install CognitiveServices.Translator.Client as a Cake Addin #addin nuget:?package=CognitiveServices.Translator.Client&version=1.0.0 // Install CognitiveServices.Translator.Client as a Cake Tool #tool nuget:?package=CognitiveServices.Translator.Client&version=1.0.0
CognitiveServices.Translator.Client
Microsoft Cognitive Services client. This code/package tries to cover the version 3 (V3) of the Translator Text API reference
. Basically, we can have 2,000,000 character translated per month using that API. Also, it provides some feature that other API are not (like what was translated by what within the translate service).
Target
This library targets the NetStandard 2.0, so you can use it within .Net Core 2.0.
Cover the following implementations
- Translate API
- 100% implemented.
- Automated integration tests should be added in order to detect changes in the API.
- Transliterate API
- Not yet available
- Detect API
- Not yet available
- Break sentence API
- Not yet available
- Dictionary Lookup API
- Not yet available
- Dictionary Example API
- Not yet available
How to install
Simply install using the Nuget package manager on your project and search for the CognitiveServices.Translator.Client
package.
Or, you may simply use the command line and do Install-Package CognitiveServices.Translator.Client -Version 1.0.0
.
How to use
A few choices exists, I will be presenting the most common scenario with the DI (Dependency Injection).
appsettings.json
In the settings, add the following:
"CognitiveServices": {
"Name": "Doc_Transl_demo",
"SubscriptionKey": "[Insert Key here]",
"SubscriptionKeyAlternate": "Second key here"
}
Startup.cs
// During the service registration
services.AddCognitiveServices(configuration); // where configuration is IConfiguration
services.AddScoped<ITranslate, SampleClassWithInjection>(); // Where ITranslate is your own interface, not something required.
SampleClassWithInjection.cs
public class SampleClassWithInjection: ITranslate {
private readonly ITranslateClient _translateClient;
private readonly ILogger<SampleClassWithInjection> _logger;
public SampleClassWithInjection(ITranslateClient translateClient, ILogger<SampleClassWithInjection> logger) {
_translateClient = translateClient;
_logger = logger;
}
public IList<ResponseBody> TranslateSomething(string text) {
var response = _translateClient.Translate(
new RequestContent(text),
new RequestParameter
{
From = "ja", // Optional, will be auto-discovered
To = new[] { "en" }, // You can translate to multiple language at once.
IncludeAlignment = true, // Return what was translated by what. (see documentation)
});
// response = array of sentenses + array of target language
_logger.LogDebug(response.First().Translations.First().Text);
return response;
}
}
By example: If I send Aćć
, I wil receive Mr.A.
. (Better example to come)
Author(s)
- @Nordes (me)
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Configuration.Binder (>= 2.0.2)
- Microsoft.Extensions.DependencyInjection (>= 2.0.0)
- Newtonsoft.Json (>= 11.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CognitiveServices.Translator.Client:
Package | Downloads |
---|---|
JapaniseTextClassifier
JapaniseTextClassifier classifies whether Japanese text contains sexual or unpleasant expressions. As of August 2019, each cloud vendor's (Azure, GCP, etc) text classification SaaS is only available in English. Therefore, JapaniseTextClassifier translates Japanese into English before classification. You can specify which cloud vendor's SaaS is used for translation and classification. |
GitHub repositories
This package is not used by any popular GitHub repositories.