GTranslate 2.3.0
dotnet add package GTranslate --version 2.3.0
NuGet\Install-Package GTranslate -Version 2.3.0
<PackageReference Include="GTranslate" Version="2.3.0" />
paket add GTranslate --version 2.3.0
#r "nuget: GTranslate, 2.3.0"
// Install GTranslate as a Cake Addin #addin nuget:?package=GTranslate&version=2.3.0 // Install GTranslate as a Cake Tool #tool nuget:?package=GTranslate&version=2.3.0
GTranslate
GTranslate is a collection of free translation APIs (Google Translate, Bing Translator, Microsoft Translator and Yandex.Translate). Currently supports translation, transliteration, language detection and text-to-speech.
Features
5 translation services:
- Google Translate (old and new APIs)
- Bing Translator
- Microsoft Azure Translator
- Yandex.Translate
Support for translation, transliteration, language detection and text-to-speech in the included translators.
Support for all the languages of each translator.
A language class with methods for getting the supported languages and determining the availability of a language in a specific translator.
Interfaces, allowing to write custom translators and languages.
An
AggregateTranslator
class that groups the default translators for ease of use with the ability to add custom translators.
Installation
Install via NuGet
Or via command:
dotnet add package GTranslate
Usage
Translation
using GTranslate.Translators;
// Create an instance of the Google Translator
var translator = new GoogleTranslator();
// Translate "Hello world" to Spanish (es)
var result = await translator.TranslateAsync("Hello world", "es");
Console.WriteLine(result);
// Output:
// Translation: 'Hola Mundo', TargetLanguage: 'Spanish (es)', SourceLanguage: 'English (en)', Service: GoogleTranslator
Transliteration
Transliteration is similar to translation but way it works is specific to each translator. Some translators only support transliteration implicitly and others have dedicated transliteration endpoints (like Yandex).
using GTranslate.Translators;
var translator = new YandexTranslator();
// Transliterate "Hello world" (in Russian) into English (latin script)
var result = await translator.Transliterate("Привет, мир", "en");
Console.WriteLine(result);
// Output:
// Transliteration: 'privet, mir', TargetLanguage: 'English (en)', SourceLanguage: 'Russian (ru)', Service: YandexTranslator
It's recommended to use MicrosoftTranslator
for transliteration because of its superior API that allows you to explicitly specify the source and target script.
Languages
GTranslate provides an easy way to access languages through the Language
class. A Language
object contains the English name, native name, ISO 639-1 code, ISO 639-3 code and the supported services (translation engines).
To get a Language
object from its ISO 639-1 code, use the Language.GetLanguage
or Language.TryGetLanguage
methods. If the language was not found Language.GetLanguage
will throw an exception and Language.TryGetLanguage
will simply return false
.
A language can also be obtained through its English/native name, ISO-6393 code and some aliases (like zh-Hans
or zh-Hant
).
using GTranslate;
var french = Language.GetLanguage("fr"); // Get the French language
string input = Console.ReadLine();
if (Language.TryGetLanguage(input, out var language)
{
// Use language from input
}
GTranslate exposes the complete list of languages through a language dictionary class LanguageDictionary
which can be accessed through Language.LanguageDictionary
.
It is essentially a read-only dictionary of ISO 639-1 codes and their respective languages.
Results
Calling TranslateAsync
returns an object deriving from ITranslationResult
. It contains the translation, souce text, service, source language and target language.
The same applies to TransliterateAsync
and ITransliterationResult
but the transliteration is present instead of the translation.
Some translation engines will provide results with extra data in them. This extra data is exposed through properties in their concrete classes. For example, GoogleTranslationResult
from (GoogleTranslator.TranslateAsync
) will sometimes provide the confidence of the translation and the transliteration.
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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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 is compatible. |
.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
- System.Net.Http.Json (>= 9.0.2)
- System.Text.Json (>= 9.0.2)
-
.NETStandard 2.1
- System.Net.Http.Json (>= 9.0.2)
- System.Text.Json (>= 9.0.2)
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on GTranslate:
Package | Downloads |
---|---|
DynamicTranslate
Translate Netesd Poco objects content at run time |
|
MaIN.NET
MaIN.NET - Package designed to streamline the integration of large language models (LLMs) into advanced AI workflows. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on GTranslate:
Repository | Stars |
---|---|
lingarr-translate/lingarr
Lingarr is an application that supports both local and SaaS translation services to translate subtitle files into a specified target language. With automated translation options, Lingarr simplifies translating subtitles.
|
|
PavlikBender/ScreTran
Простой экранный переводчик, screen translator
|
Version | Downloads | Last updated |
---|---|---|
2.3.0 | 438 | 3/4/2025 |
2.2.8 | 14,660 | 9/27/2024 |
2.2.7 | 654 | 8/14/2024 |
2.2.6 | 204 | 8/5/2024 |
2.2.5 | 149 | 7/31/2024 |
2.2.3 | 117 | 7/26/2024 |
2.2.0 | 1,522 | 5/26/2024 |
2.1.6 | 38,021 | 3/13/2023 |
2.1.5 | 346 | 3/10/2023 |
2.1.3 | 536 | 1/13/2023 |
2.1.1 | 5,265 | 7/28/2022 |
2.1.0 | 2,054 | 4/23/2022 |
2.0.2 | 651 | 4/7/2022 |
2.0.1 | 613 | 2/26/2022 |
2.0.0 | 494 | 2/19/2022 |
1.0.3 | 920 | 6/22/2021 |