saxulum-translation-provider
works with plain silex-php
Features
- Register translations
Requirements
- php >=5.3
- Symfony Config Component >=2.3
- Symfony Finder Component >=2.3
- Symfony Translation Component >=2.3
- Symfony Yaml Component >=2.3
Installation
Through Composer as saxulum/saxulum-translation-provider.
Preparation (for non silex users)
Debug value is needed
$container['debug'] = true; // or false
Define translator service
$container['translator'] = function () {
return new Translator('en');
};
For all users
With translation cache (faster)
use Saxulum\Translation\Silex\Provider\TranslationProvider;
$container->register(new TranslationProvider(), array(
'translation_cache' => '/path/to/cache'
));
debug == true
: the cache file will be build at each loaddebug == false
: the cache file will be build if not exists, delete it if its out of sync
Without translation cache (slower)
use Saxulum\Translation\Silex\Provider\TranslationProvider;
$container->register(new TranslationProvider());
Usage
Add the translation paths
$container['translation_paths'] = $container->extend('translation_paths', function ($paths) {
$paths[] = '/path/to/the/translations';
return $paths;
});