Git Product home page Git Product logo

quicktranslate's Introduction

quicktranslate

Ultralight phrase translation using Google Translate API

Starting Out

Before anything else, you'll need to setup your own Google Cloud project and get an API key. Once you have that, create a variables.env file at the root of this repo and add it as the value of GOOGLE_API=.

Usage

Clone the repo, and then npm install. Any version of Node greater than 7 works, but you could just as easily nvm use in the repo's root and .nvmrc will take care of that for you. You can see a very simple demonstration by running npm start in your console, which will:

  • import the phrases found in ./src/sample.js (which is just a basic JavaScript array)
  • define your languages in ./src/languages.js (another array)
  • translate each phrase in the array to a target language (pass the ISO-639-1 Code as an argument on line 20 of app.js)
  • write a new file in ./dist as a JavaScript object with original phrases as the keys and translated phrases as values

Sample

Here's the sample output in 🇮🇹🇩🇪🍕 Italian & German 🍕🇩🇪🇮🇹:

{
  "doYouHaveJalapenos": {
    "en-us": "Do you have jalapeños?",
    "de": "Hast du Jalapeños?",
    "it": "Hai jalapeños?"
  },
  "orderPizza": {
    "en-us": "I'd like to order a {large_pizza}, please.",
    "de": "Ich möchte bitte eine {large_pizza} bestellen.",
    "it": "Vorrei ordinare un {large_pizza}, per favore."
  },
  "extraToppings": {
    "en-us": "Yes, please add <div ng-repeat=\"topping in $ctrl.getToppings()\"><span ng-bind=\"::topping.name\"></span></div>.",
    "de": "Ja, bitte <div ng-repeat=\"topping in $ctrl.getToppings()\"><span ng-bind=\"::topping.name\"></span></div> hinzufügen.",
    "it": "Sì, aggiungi <div ng-repeat=\"topping in $ctrl.getToppings()\"><span ng-bind=\"::topping.name\"></span></div>."
  }
}

quicktranslate's People

Watchers

James Cloos 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.