lsv / google-translation-bundle
Symfony bundle to translate text with google translation
Installs: 35
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=8.3
- google/cloud-translate: ^1.19
- symfony/config: ^7
- symfony/console: ^7
- symfony/dependency-injection: ^7
- symfony/http-kernel: ^7
Requires (Dev)
- ergebnis/license: ^2.5
- friendsofphp/php-cs-fixer: ^3.64
- infection/infection: ^0.29.8
- matthiasnoback/symfony-dependency-injection-test: ^6.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.12
- phpstan/phpstan-symfony: ^1.4
- phpunit/phpunit: ^11.4
- roave/security-advisories: dev-latest
- rregeer/phpunit-coverage-check: ^0.3.1
- symfony/stopwatch: ^7
This package is auto-updated.
Last update: 2024-10-31 21:25:00 UTC
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