happyr / auto-fallback-translation-bundle
1.0.1
2016-11-12 20:13 UTC
Requires
- php: ^5.5 || ^7.0
- php-http/client-implementation: ^1.0
- php-http/httplug: ^1.0
- php-http/plugins: ^1.0
- psr/log: ~1.0
- symfony/framework-bundle: ^2.7 || ^3.0
Requires (Dev)
- matthiasnoback/symfony-dependency-injection-test: ^1.0
- php-http/guzzle6-adapter: ^1.0
- phpunit/phpunit: ^4.5 || ^5.4
- symfony/symfony: ^2.3 || ^3.0
Suggests
- php-http/httplug-bundle: To easier configure your httplug clients.
README
已弃用: 使用 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。