herrera-io/silex-translation-files

A Silex service provider for using translation files.

1.1.0 2013-08-15 20:25 UTC

README

Build Status

This is a Silex service provider that extends the existing Translation service in order to more easily support the use of translation files. You can specify the loader, the files, and the locales all as a parameter.

Example

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

Installation

Use Composer:

$ composer.phar require "herrera-io/silex-translation-files=~1.0"