Giter Club home page Giter Club logo

googletranslatefreeapi's Introduction

GoogleTranslateFreeApi

Api for free text translation using Google translate.

This repo is exactly the same as the one from Grizley56, bud with a good ban prevention. When you use this free api without this ban prevention, you will get blocked after like 20 requests or so. This mechanism prevents this and you will not get blocked for a couple hours. It keeps on working.

I tried to contact Grizley56, bud he did not respond.

Main features:

  • Text corrections
  • Language corrections
  • Language auto detection
  • Transcriptions (original text, translated text)
  • Synonyms
  • Definitions + Examples
  • Extra translations
  • Proxy (Useful when getting a ban for a while)

Feature TranslateLiteAsync TranslateAsync
Text corrections + +
Language corrections + +
Language auto detection + +
Transcriptions + +
Synonyms - +
Definitions + Examples - +
Extra translations - +
See Also - +

Usage

Translation, transcription and text/language corrections

var translator = new GoogleTranslator();

Language from = Language.Auto;
Language to = GoogleTranslator.GetLanguageByName("Japanese");

TranslateResult result = await translator.TranslateLiteAsync("Hello. How are you?", from, to);

//The result is separated by the suggestions and the '\n' symbols
string[] resultSeparated = result.FragmentedTranslation;

//You can get all text using MergedTranslation property
string resultMerged = result.MergedTranslation;

//There is also original text transcription
string transcription = result.TranslatedTextTranscription; // Kon'nichiwa! Ogenkidesuka?

Language auto detection and correction

Language detectedLanguage = result.SourceLanguage;
Console.WriteLine(detectedLanguage.FullName);
// English
Console.WriteLine("Confidence: " + result.Corrections.Confidence); // number from 0 to 1

Language spanish = new Language("Spanish", "es"); // For the method, only the second parameter is important (ISO639)

var result2 = await translator.TranslateLiteAsync("world", spanish, GoogleTranslator.GetLanguageByName("Russian"));

if(result2.Corrections.LanguageWasCorrected) // true
  Console.WriteLine($"The source language has been changed to {result2.Corrections.CorrectedLanguage.FullName}");

Console.WriteLine(result2.MergedTranslation) // мир

Text corrections

string misspellingsText = "The quik brown fox jumps ovver the lazy dog"
var english = new Language("English language", "en");
Console.WriteLine(GoogleTranslator.IsLanguageSupported(english)); // true
var result3 = await translator.TranslateLiteAsync(misspellingsText, english, GoogleTranslator.GetLanguageByISO("ru"));

if(result3.Corrections.TextWasCorrected)
  foreach(string correctedWord in result3.Corrections.CorrectedWords)
    Console.WriteLine(correctedWord + " "); // "quick", "over"

Console.WriteLine(result3.MergedTranslation) // "Быстрая коричневая лиса прыгает через ленивую собаку"

Synonyms, extra translations, definitions and so on.

GoogleTranslator translator = new GoogleTranslator();

var result4 = await translator.TranslateAsync(
  "книга", GoogleTranslator.GetLanguageByName("Russian"), GoogleTranslator.GetLanguageByName("English"));

if(result.ExtraTranslations != null)
  Console.WriteLine(result.ExtraTranslations.ToString()); // ToString returns friendly for reading string
  

Example of ToString output:

Noun:
book: книга, книжка, журнал, книжечка, том, текст
volume: объем, том, громкость, книга, емкость, масса
Abbreviation:
bk: книга, назад, обратно

You can also get any part of the speech indently

foreach(ExtraTranslation item in result4.ExtraTranslations)
  Console.WriteLine($"{item.Phrase}: {String.Join(", ", item.PhraseTranslations)}); 
  // just like item.ToString()

There are other translate information getting by the same principe

  • Definitions
  • Synonyms
  • See also

Google Translate can ban IP that sends too many requests at the same time. Ban lasts about a few hours, but you can use a Proxy

var proxy = new WebProxy(uri); // You also can use GoogleTranslateFreeApi.Proxy class for this
translator.Proxy = proxy;

LICENSE

Released under the MIT License.

This repository сontains part of the code from the library google-translate-token

googletranslatefreeapi's People

Contributors

grizley56 avatar bramscochill avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.