1. Go to this page and download the library: Download knone/translate-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/ */
knone / translate-bundle example snippets
bash
php composer.phar
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new KNone\TranslateBundle\KNoneTranslateBundle(),
);
}
php
...
// Some action in controller
public function someAction()
{
/** @var KNone\TranslateBundle\Provider\ProviderInterface $translator */
$translator = $this->get('k_none_translate.translator');
$translation = $translator->translate('hello world', 'en', 'fr');
// you can set 'auto' as source language and translator will detect it
//$translation = $translator->translate('hello world', 'auto', 'fr');
$result = (string)$translation; // $result contains 'bonjour tout le monde'
$result = $translation->getResult(); // $result contains 'bonjour tout le monde'
$source = $translation->getSource(); // $source contains 'hello world'
$sourceLanguage = $translation->getSourceLanguage() // $sourceLanguage contains 'en'
$resultLanguage = $translation->getResultLanguage() // $resultLanguage contains 'fr'
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.