lsv/google-translation-bundle
最新稳定版本:v1.0.1
Composer 安装命令:
composer require lsv/google-translation-bundle
包简介
Symfony bundle to translate text with google translation
README 文档
README
Usage
Command
bin/console google-translate:detect "your text here to detect language code used" bin/console google-translate:translate "da" "your text here to translate"
Service
<?php use Lsv\GoogleTranslationBundle\Translate\TranslatorInterface; final readonly class TranslateText { public function __construct( private TranslatorInterface $translator, ) { } public function translate(string $text): string { return $this->translator->translate($text, 'en', isHtml: true)->text; } }
Installation
composer require lsv/google-translate-bundle
You need to get a Google API key from the Google Cloud Console, and change it in your environment file.
With flex
The bundle will be automatically enabled and the configuration will be added to your .env file.
Without flex
Add the bundle to your config/bundles.php file
return [ // ... Lsv\GoogleTranslationBundle\GoogleTranslationBundle::class => ['all' => true], ];
Configuration
# config/packages/google_translation.yaml lsv_google_translate: google_api_key: '%env(GOOGLE_API_KEY)%'
# .env
GOOGLE_API_KEY=your_api_key_here
统计信息
- 总下载量: 50
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-31