PHP Classes


Recommend this page to a friend!
  Classes of Ujah Chigozie peter  >  PHP Google Translate Text Form  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP Google Translate Text Form
Show form to translate text with Google Translate
Author: By
Last change:
Date: 8 months ago
Size: 2,201 bytes


Class file image Download


Php wrapper for google javascript translator website plugin. It will create a dropdown option for languages.

alt text alt text


Installation is super-easy via Composer:

composer require peterujah/php-google-translator


use Peterujah\NanoBlock\GTranslator;
$translate = new GTranslator("en", "/assets/flags/");

set selector design provider, you can choose between DEFAULT style and BOOTSTRAP. The DEFAULT is the default provider

$this->setProvider(GTranslator::DEFAULT || GTranslator::BOOTSTRAP);

Set the fag icon type, PNG or SVG to use icons download country flag icon and set the Relative or Absolute path

$translate->setIconType(GTranslator::PNG || GTranslator::SVG);

Add additional langues

 $translate->addLanguage("en", "English")->addLanguage("ig", "Igbo");

Load languages

  "en" => "English",
  "ig" => "Igbo"

Full usage on website to translate webpage

 use Peterujah\NanoBlock\GTranslator;
 $translate = new GTranslator("en", "/assets/flags/");
<!DOCTYPE html>
<html lang="en">
    <title>PHP Google Translator</title>
      <div class="button">
        <?php $translate->button();?>
      <div class="content">
        <h2>We have a long history of service in the Bay Area</h2>

          We were one of the first credit unions that operate world wide, founded in 1932 as City &amp; County Employees' Credit Union. 
          Membership is now open to anyone who lives, works, or attends school in 
          Alameda, Contra Costa, San Joaquin, Solano, Stanislaus, or Kings counties in California. 
          We believe in banking locally and hope you will too. 
      <?php $translate->load();?>