chiarillomax/yandex-translator-bundle

Yandex 译者在 Symfony2 中的集成

安装: 294

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

开放问题: 0

类型:symfony-bundle

V1.2 2016-04-20 13:25 UTC

This package is not auto-updated.

Last update: 2024-09-25 23:24:10 UTC


README

SensioLabsInsight Scrutinizer Code Quality Build Status

在您的 Symfony 项目中使用 Yandex 译者服务

安装

安装捆绑包

composer require chiarillomax/yandex-translator-bundle

app/AppKernel.php 中注册捆绑包

<?php
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new \Yandex\TranslatorBundle\YandexTranslatorBundle()
    );
}

使用

//use Yandex\TranslatorBundle\Model\Key
$key = new Key();
$key->setValue('YourKey');

$request = $this->get('yandex.translator')->createRequest()
     ->setKey($key->getValue())
     ->setText('Hello Max')
     ->setFrom('en')
     ->setTo('it')
     ->send();

$text = $request->getText(); //Ciao Max

测试

phpunit