Download the PHP package peterujah/php-google-translator without Composer
On this page you can find all versions of the php package peterujah/php-google-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download peterujah/php-google-translator
More information about peterujah/php-google-translator
Files in peterujah/php-google-translator
Package php-google-translator
Short Description PHP Google Javascript Website Translator Plugin
License MIT
Homepage https://github.com/peterujah/php-google-translator
Informations about the package php-google-translator
PHP Google Translator
A lightweight PHP wrapper for the Google Translate JavaScript plugin.
This library allows you to easily integrate a language selector into your website, supporting:
- Dropdown or image/button selectors for multiple languages.
- Automatic browser language detection and preferred language settings.
- Customizable UI with options for default, select, or Bootstrap-styled dropdowns.
- Flexible icon support with PNG or SVG flags from a local or remote path.
- Full control over CSS classes for containers and items.
Designed to simplify adding multilingual support to your site while keeping integration straightforward.

Installation
Installation is super-easy via Composer:
Usage
Initialize the translator
With a base path for flag icons:
Without specifying an icon path:
Set the selector provider
Choose between:
GTranslator::DEFAULT(default HTML dropdown or image button)GTranslator::SELECT(HTML select dropdown)GTranslator::BOOTSTRAP(Bootstrap dropdown)
Configure icon path and type
Set the relative or absolute path for your flag icons and choose between GTranslator::PNG or GTranslator::SVG:
Or using an external URL:
Manage languages
Add additional languages individually:
Or override the default language map:
Display the language selector
Render the selector with an optional width (default "170px"):
Behavior depends on the provider:
GTranslator::SELECT→ returns a<select>element.GTranslator::BOOTSTRAP→ returns a bootstrap dropdown<li>element.GTranslator::DEFAULT→ returns an image/button interface:
Image JS trigger button uses GTranslator::DEFAULT
Load the translator engine
Include the Google Translate JS and CSS:
Customize classes
Set the container class:
Set individual item classes:
Control language behavior
Set a preferred language (must be after load()):
Automatically detect the browser language (must be after load()):