PHP code example of lsv / google-translation-bundle

1. Go to this page and download the library: Download lsv/google-translation-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lsv / google-translation-bundle example snippets




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;
    }
}

return [
    // ...
    Lsv\GoogleTranslationBundle\GoogleTranslationBundle::class => ['all' => true],
];