PHP Classes

GoogleTrnsltr PHP Google Translate API Library: Translate texts between languages using Google API

Recommend this page to a friend!

  Author Author  
Picture of Rafael Martin Soto
Name: Rafael Martin Soto <contact>
Classes: 13 packages by
Country: Spain Spain
Age: 48
All time rank: 248963 in Spain Spain
Week rank: 31 Up1 in Spain Spain Up
Innovation award
Innovation award
Nominee: 7x

Winner: 4x


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can translate texts between languages using Google API.

It can take as a parameter a text string in a given language and send an HTTP request to the Google Translate API.

The class returns the text of the text string parameter value translated to another given language.

The class returns a JSON encoded string of the object returned by Google Translate API with the results of the text translation.

Details

GoogleTrnsltr. PHP Class to translate texts with Google Translator Api

BEWARE: Google Translator API is a PAYMENT Service of Google

V.1.0.0

Source donated by https://bio-farma.es

# REQUERIMENTS:

- A minimum (minimum, minimum, minimum requeriments is needed). Tested on:

- Simple Raspberry pi (B +	512MB	700 MHz ARM11) with Raspbian Lite PHP7.3 (i love this gadgets)  :heart_eyes:

- VirtualBox Ubuntu Server 20.04.2 LTS (Focal Fossa) with PHP7.4.3 

- Ubuntu 20.04.3 LTS (Focal Fossa). Laptop Acer Extensa 5630 with PHP 7.4.3 (built: Aug 13 2021 05:39:12) ( NTS )

- Red Hat Enterprise Linux Server release 6.10 (Santiago) PHP Version 7.3.25 (Production Server) 512Mb Memory Limit

- Red Hat Enterprise Linux release 8.5 (Ootpa) PHP Version 8.0.14

# FILES: There are 2 basic files:

GoogleTrnsltr.class.php -> Master class. This file is the main file that you need to include in your code.

example.php -> example file

# INSTALLATION: A lot of easy :smiley:. It is written in PURE PHP. Only need to include the files. Tested on basic PHP installation

     require_once( 'GoogleTrnsltr.class.php' );
 

# BASIC USAGE:

      $GoogleTrnsltr = new GoogleTrnsltr( 'IMPORTANT_CHANGE_HERE-YOUR-GOOGLE-TRANSLATOR-API-KEY' ); // See https://cloud.google.com/translate/docs/setup
      echo $GoogleTrnsltr->tnrltSrcTgt( 'Hello World!', 'en', 'es' ); // Echo { "data": { "translations": [ { "translatedText": "Hola Mundo!" } ] } }

RESUME OF METHODS:

  • CREATE GoogleTrnsltr:

$GoogleTrnsltr= new GoogleTrnsltr( 'YOUR-API-KEY' ); // See https://cloud.google.com/translate/docs/setup

Example:

     $GoogleTrnsltr= new GoogleTrnsltr( 'ALN23IJDAS89A61Q34UHASHUDFSHUDFASHUDASHUDA8923834671234' ); // Random key. Do not use it. Change with your API KEY

  • GET TRANSLATED TEXT:

    Give a text, language_from and language_to. It returns JSON format with translated text

tnrltSrcTgt( $q, $source, $target, $utf8Format = true );

Example:

	echo $GoogleTrnsltr->tnrltSrcTgt( 'Hello World!', 'en', 'es' ); // Echo { "data": { "translations": [ { "translatedText": "Hola Mundo!" } ] } }
   

Of course. You can use it freely :vulcan_salute::alien:

By Rafa.

@author Rafael Martin Soto

@author {@link http://www.inatica.com/ Inatica}

@blog {@link https://rafamartin10.blogspot.com/ Rafael Martin's Blog}

@link https://bio-farma.es

@since DECEMBER 2021

@version 1.0.0

@license GNU General Public License v3.0


  Classes of Rafael Martin Soto  >  GoogleTrnsltr PHP Google Translate API Library  >  Download Download .zip .tar.gz  >  Support forum Support forum (1)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: GoogleTrnsltr PHP Google Translate API Library
Base name: googletrnsltr
Description: Translate texts between languages using Google API
Version: 1.0.0
PHP version: 5
License: GNU General Public License (GPL)
All time users: 90 users
All time rank: 9774
Week users: 1 user
Week rank: 206 Up
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image Localization Internationalization and translations View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Text processing Manipulating and validating text data View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes


  User ratings  
Not yet rated by the users

  Applications that use this package  
bio-farma.es
Used to autotranslate products & others descriptions

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Plain text file GoogleTrnsltr.class.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

Install with Composer Install with Composer - Download Download all files: googletrnsltr.tar.gz googletrnsltr.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
For more information send a message to info at phpclasses dot org.