Giter VIP home page Giter VIP logo

open-google-translator's Introduction

open-google-translator

npm version license

A versatile and easy-to-use NPM package that leverages the power of the Google Translator API. With support for 104 languages, this package can seamlessly translate text in both web and Node.js environments.

Installation

npm install open-google-translator

Usage

Node.js

const translator = require("open-google-translator");

translator.supportedLanguages();

translator
  .TranslateLanguageData({
    listOfWordsToTranslate: ["hello here i am", "HI hello"],
    fromLanguage: "en",
    toLanguage: "hi",
  })
  .then((data) => {
    console.log(data);
  });
  • translator.supportedLanguages(); this method will provide pair of language iso639-1 language codes with respective language original names

    Example: { af: "Afrikaans", sq: "Albanian", am: "Amharic", ar: "Arabic", hy: "Armenian", az: "Azerbaijani", eu: "Basque",......}

Browser

1.Include the script in your HTML file:

<script src="https://cdn.statically.io/gh/vidya-hub/open-google-translator/main/dist/bundle.js"></script>

2.Access the package methods using the openGoogleTranslator variable:

openGoogleTranslator
  .TranslateLanguageData({
    listOfWordsToTranslate: ["hello here i am", "HI hello"],
    fromLanguage: "en",
    toLanguage: "te",
  })
  .then((data) => {
    console.log(data);
  });

Inputs

  • listOfWordsToTranslate: An array of sentences to be translated.
  • fromLanguage: The language code of the original text (e.g., "en" for English).
  • toLanguage: The language code of the target translation (e.g., "hi" for HIndi).

Output

The output consists of an array of objects, each containing the original and translated sentences.

[
  { original: "hello here i am", translation: "नमस्ते मैं यहाँ हूँ" },
  { original: "HI hello", translation: "हाय हैलो" },
];

Features

  • Supports translation for 104 languages.
  • Works seamlessly in both Node.js and browser environments.
  • Simple and intuitive API for easy integration.
  • Fast and efficient unlimited translation using the free Google Translator API.

Contributing

If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer 📝

Please be aware that this package is created exclusively for educational purposes. The token generation method employed in this package is based on the one utilized by https://translate.googleapis.com. It is important to note that for other types of usage (COMMERCIAL or PRODUCTION use), acquiring the official Google Translator API is recommended.

open-google-translator's People

Contributors

vidya-hub avatar

Watchers

Lokesh Jasthi 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.