PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Ujah Chigozie peter  >  PHP Google Translate Text Form  >  README.md  >  Download  
File: README.md
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
 

Contents

Class file image Download

php-google-translator

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

alt text alt text

Installation

Installation is super-easy via Composer:

composer require peterujah/php-google-translator

USAGES

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);
$translate->setIconPath("https://foo.com/assets/flags/");

Add additional langues

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

Load languages

 $translate->setLanguages([
  "en" => "English",
  "ig" => "Igbo"
 ])

Full usage on website to translate webpage

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

        <p>
          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. 
        </p>
      </div>
      <?php $translate->load();?>
  </body>
</html>