GithubHelp home page GithubHelp logo

00mjk / gtranslatorapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from franck-gaspoz/gtranslatorapi

0.0 0.0 0.0 118 KB

Google Translate Rest API (Free) - .NET Core 5 , .NetStandard2.1

License: Other

C# 100.00%

gtranslatorapi's Introduction

GTranslatorAPI

Google Translate Rest API (Free) - .NET Core 5 , .NetStandard2.1 VSCode / Visual Studio


licence mit This project is licensed under the terms of the MIT license: LICENSE.md

last commit version

a C# library that deals with Google Translate REST API. Offers google translate service operations from a C# software (with no api token)

using GTranslatorAPI;

...

var translator = new Translator();

// source language, target language, text to be translated
var result = await translator.TranslateAsync(Languages.en, Languages.fr, "text to be translated");

// output translated text
System.Console.WriteLine(result);

Get the library project (vscode example)

source from GitHub:

cd myProjects
git clone https://github.com/franck-gaspoz/GTranslatorAPI.git
cd .\GTranslatorAPI\
code .

then go Run > Start Debugging , select .Net Core engine, you should get the output:

GTranslator API CLI 2.0.0.0
(c) [email protected] 2021 License MIT

command line syntaxes:

    source_langid target_langid text [-q] [-w]
        source_langid : original text lang id
        target_langid : translated text lang id
        q : turn off all outputs excepting errors

    -l | --list [-w]
        l | list : dump list of languages ids & names

        w : wait a key press before exit

package from nuget:

dotnet add package GTranslatorAPI --version 2.0.0 --source https://www.nuget.org/api/v2/package/

package from GitHub:

dotnet add package GTranslatorAPI --version 2.0.0 --source https://nuget.pkg.github.com/franck-gaspoz/index.json

Use the library

let's build a new C# console project for testing the GTranslatorAPI nuget package, using powershell, dotnet and vscode :

mkdir MyProject
cd MyProject
dotnet new console
dotnet add package GTranslatorAPI --version 2.0.0
code .

let's change the default main method in Program.cs, to change its default behavior (output 'Hello world!') by a new one, that adds a translation of 'Hello world!' to spanish, using the GTranslatorAPI :

using System;
using GTranslatorAPI;

namespace MyProject
{
    class Program
    {
        static async Task Main(string[] args)
        {
            string s = "Hello world!";
            Console.WriteLine(s);
            
            var translator = new Translator();
            var result = await translator.TranslateAsync(Languages.en,Languages.es,s);         
            
            Console.WriteLine(result.TranslatedText);    
            
            Console.WriteLine(dbg);
        }
    }
}

then run the project (ctrl+F5 | Run > Start without debugging). You should get:

run sample in vscode


ℹī¸ About this repository

To go further, please read informations at : http://franckgaspoz.fr/en/use-google-translate-for-free-on-the-command-line/ or contact the autor

gtranslatorapi's People

Contributors

franck-gaspoz avatar kevinzonda 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.