2017 © Pedro Peláez
 

library google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

image

aurawindsurfing/google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

  • Wednesday, May 30, 2018
  • by aurawindsurfing
  • Repository
  • 1 Watchers
  • 1 Stars
  • 156 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel package for Google Translate REST API

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require, (*1)

Package allows to work with Google Translate API, (*2)

Installation

Package can be installed using composer by adding to "require" object, (*3)

"require": {
    "aurawindsurfing/google-translate"
}

or from console:, (*4)

composer require aurawindsurfing/google-translate

Configuration

After the installation, you should add "Dedicated\GoogleTranslate\GoogleTranslateProvider" to providers., (*5)

        'providers' => [
                /* 3rd Party Providers */
                Dedicated\GoogleTranslate\GoogleTranslateProvider::class,
         ],

Then you should publish config file to be able to add your Google API key. To publish config you should do:, (*6)

php artisan vendor:publish \
--provider="Dedicated\GoogleTranslate\GoogleTranslateProvider" --tag=config

After config is published, you will have it in config\google-translate.php of your Laravel project directory, (*7)

You should change only one line:, (*8)

    ...

    /**
     * Google key for authentication
     */
    'api_key' => 'YOUR-GOOGLE-API-KEY-GOES-HERE',

    ...

Usage

To translate text with given source language and target language:, (*9)

$translator = new Dedicated\GoogleTranslate\Translator;


$result = $translator->setSourceLang('en')
                     ->setTargetLang('ru')
                     ->translate('Hello World');

dd($result); // "Привет мир"                           


, (*10)

By default language detection is turned on, so you can translate text without specifying source language., (*11)

This will make 2 requests to google API:, (*12)

  • First request will go to /detect URL and get source language name
  • Second request will make actual translate request and give out result.
$translator = new Dedicated\GoogleTranslate\Translator;


$result = $translator->setTargetLang('ru')
                     ->translate('Hello World');

dd($result); // "Привет мир"                           

You can also use function to only detect text's source language:, (*13)


$result = $translator->detect('Hello World'); dd($result); // "en"

License

This repository code is open-sourced software licensed under the MIT license., (*14)

The Versions

30/05 2018

dev-master

9999999-dev https://github.com/aurawindsurfing/google-translate

Free Laravel package for Paid Google Translate REST API with your own API key

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arturs Terehovics
by Tomasz Lotocki

laravel php google translate

05/03 2016

1.0.0

1.0.0.0 http://github.com/ddctd143/google-translate

Free Laravel package for Paid Google Translate REST API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arturs Terehovics

laravel php google translate