lsoft/translator-bundle

LSoft 对 Avro symfony2 bundle 的改进版本,使用第三方翻译 API 进行文本翻译

1.0.0 2016-03-25 12:27 UTC

This package is not auto-updated.

Last update: 2024-09-18 17:37:42 UTC


README

一个使用 Microsoft Translator 进行文本翻译的 Symfony2 bundle。与 Google 翻译不同,Microsoft 翻译有一个免费的计划,每月可以翻译 2,000,000 个字符。

请参阅Microsoft Translator 文档,了解如何设置 Azure 账户以获取您的 clientID 和 client secret。

安装

$ composer install avro/translator-bundle

将 bundle 添加到 AppKernel。

    new Avro\TranslatorBundle\AvroTranslatorBundle(),

配置

avro_translator:
    azure:
        client_id: %azure_client_id%
        client_secret: %azure_client_secret%

使用方法

翻译器作为一个服务提供

// translate some text from english to spanish
$newText = $this->container->get('avro_translator.translator')->translate('Some text here', 'en', 'es');

许可证

MIT