PHP code example of herrera-io / silex-translation-files

1. Go to this page and download the library: Download herrera-io/silex-translation-files 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/ */

    

herrera-io / silex-translation-files example snippets


use Herrera\Silex\Provider\TranslationServiceProvider;
use Silex\Application;

$app = new Application();

$app->register(
    new TranslationServiceProvider(),
    array(
        'translation.files' => array(
            'Symfony\\Component\\Translation\\Loader\\YamlFileLoader' => array(
                '/path/to/file.de.yml' => 'de',
                '/path/to/file.en.yml' => 'en',
                '/path/to/file.fr.yml' => 'fr'
            )
        )
    )
);

$translated = $app['translator']->trans($key);