At my company, we use the Google Translate API to translate our product documentation from English to French and Spanish. The translation quality is impressive. You may still need to rephrase a few sentences, but the results are consistently good.
The Google Translate service is straightforward to set up:
Install the Google Cloud SDK: https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe
Run the following command to authenticate with Google services. Your code will use this account automatically when no credentials are set in code, which is convenient during development.
Shell
gcloud auth application-default login
Install the NuGet package Google.Cloud.Translation.V2 (.NETStandard 1.3)
Use the TranslationClient
C#
var message = "This is some html text to <strong>translate</strong>!";
string targetLanguage = "fr";
string sourceLanguage = null; // automatically detected
var client = Google.Cloud.Translation.V2.TranslationClient.Create();
var response = client.TranslateHtml(message, targetLanguage, sourceLanguage);
Console.WriteLine(response.TranslatedText);
// C'est un texte html à <strong>traduire</strong> !
Google Translate automatically detects the source language, so you don't need to specify it. In some documents, there are words you may not want translated, such as function names or domain-specific terms. To prevent Google Translate from translating those words, wrap the text in a span with the class notranslate:
HTML
<span class="notranslate">text</span>
You'll find more options to control translation behavior in the documentation: https://cloud.google.com/translate/docs/
Finally, the service costs about $20 per million characters (pricing). For the translation quality and time savings it provides, that is a reasonable price.
Do you have a question or a suggestion about this post? Contact me!