charef/free-translate-api

Simple laravel package for talking to Google's Translate API for free.

v1.0.1 2022-06-16 00:43 UTC

This package is auto-updated.

Last update: 2024-05-16 05:33:41 UTC


README

Issues Stars Forks

Installation

Video Tutorial

Watch a Video Tutorial here

You need to translate your text ?

First, pull in the package through Composer.

Run composer require charef/free-translate-api

And then, if using Laravel 5 or >, include the service provider within config/app.php.

'providers' => [
    Charef\FreeTranslateApi\FreeTranslateAPIServideProvider::class,
];

And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'TranslateAPI' => Charef\FreeTranslateApi\TranslateAPI::class,
];

Usage

you need just to define source and target langage and text ...

use Charef\FreeTranslateApi\TranslateAPI;
public function translate()
{
    $source = 'ar';
    $target = 'en';
    $text = 'مرحبا';

    $result=TranslateAPI::translate($source, $target, $text);

    // Welcome
    dd($result);
}

thanks to

Adrián Barrio Andrés.