happyr / auto-fallback-translation-bundle

此包已被放弃,不再维护。作者建议使用 php-translation/symfony-bundle 包。

请确保使用Bing或Google等翻译服务来翻译缺失的消息

1.0.1 2016-11-12 20:13 UTC

This package is auto-updated.

Last update: 2022-02-01 12:53:51 UTC


README

Latest Version Build Status Code Coverage Quality Score Total Downloads

已弃用: 使用 php-translation/symfony-bundle

此包使用Google翻译您尚未翻译的消息。因此,您将获得Google翻译的字符串,而不是使用备用语言。当然,Google翻译不是最优的,但它比使用不同的语言要好得多。使用此功能,您甚至可以在翻译人员完成工作之前部署新版本。

安装

在项目根目录中运行以下命令,假设您已为项目配置了composer

composer require happyr/auto-fallback-translation-bundle

将包添加到 app/AppKernel.php

class AppKernel extends Kernel
{
  public function registerBundles()
  {
    $bundles = array(
        // ...
        new Happyr\AutoFallbackTranslationBundle\HappyrAutoFallbackTranslationBundle(),
    }
  }
}

配置

// app/config/config.yml
happyr_auto_fallback_translation:
    enabled: false
    default_locale: en
    translation_service: "google"
    google_key: "%google_server_api_key%"
    http_client: httplug.client.auto_translation
    message_factory: httplug.message_factory # default
    
 // app/config/config_prod.yml
happyr_auto_fallback_translation:
    enabled: true # Only enabled in production

要更容易配置HTTP客户端和消息工厂,请参阅 HttplugBundle