gowsram/g-translate

There is no license information available for the latest version (dev-master) of this package.

ZF2 Google Translate module

dev-master 2013-05-22 11:01 UTC

This package is not auto-updated.

Last update: 2024-04-13 12:17:13 UTC


README

Google Translate - ZF2 Module

A Zend Framework 2 Module for Google Translate

Installation

Main Setup

By cloning project

  1. This module is available on Packagist. In your project's composer.json use:

    {   
        "require": {
    		"php": ">=5.3.3",
    		"zendframework/zendframework": "*",
            "gowsram/g-translate": "dev-master"
    }
  2. Or clone this project into your ./vendor/ directory.

Post installation

  1. Enabling this module in your application.config.php file.

    return array(
        'modules' => array(
            // ...
            'GTranslate',
    		// ...
        ),
        // ...
    );

Usage

  1. In the controller

    	$gtranslate = $this->getServiceLocator()->get('GTranslate\Service\Translate');
        
        $config = array(
            'from' => 'en',   //english
            'to' => 'de',     //deutsch
        );
        
        $gtranslate->__initialize($config);
        
        $resultString = $gtranslate->translate('Hello World');
        
        return new ViewModel(array('translatedString' => $resultString));                  //passing it to the view
  2. In the View

    <?php echo $this->translatedString; ?>