saxulum / saxulum-translation-provider
Saxulum Translation Provider (yaml)
Installs: 6 345
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 2
Open Issues: 0
Requires
- php: >=5.3.9,<8.0
- pimple/pimple: >=2.1,<4
- symfony/config: ~2.3|~3.0
- symfony/finder: ~2.3|~3.0
- symfony/translation: ~2.3|~3.0
- symfony/yaml: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.1
README
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.
Silex
With translation cache (faster)
use Saxulum\Translation\Silex\Provider\TranslationProvider;
use Silex\Provider\TranslationServiceProvider;
$app->register(new TranslationServiceProvider());
$app->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;
use Silex\Provider\TranslationServiceProvider;
$app->register(new TranslationServiceProvider());
$app->register(new TranslationProvider());
Cilex
You need a service with key translator
which implements Symfony\Component\Translation\Translator
.
There is the silex ones as an example.
With translation cache (faster)
use Saxulum\Translation\Cilex\Provider\TranslationProvider;
$app['translator'] = $app->share(function(){
return new Translator;
});
$app->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\Cilex\Provider\TranslationProvider;
$app['translator'] = $app->share(function(){
return new Translator;
});
$app->register(new TranslationProvider());
Usage
Add the translation paths
$app['translation_paths'] = $app->share($app->extend('translation_paths', function ($paths) {
$paths[] = '/path/to/the/translations';
return $paths;
}));