public function initLocale()
{
// timezone
if (!empty($this['config']['timezone'])) {
date_default_timezone_set($this['config']['timezone']);
}
$this->register(new \Silex\Provider\TranslationServiceProvider(), array('locale' => $this['config']['locale'], 'translator.cache_dir' => $this['debug'] ? null : $this['config']['root_dir'] . '/app/cache/translator'));
$this['translator'] = $this->share($this->extend('translator', function ($translator, \Silex\Application $app) {
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
$file = __DIR__ . '/Resource/locale/validator.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale'], 'validators');
}
$file = __DIR__ . '/Resource/locale/message.' . $app['locale'] . '.yml';
if (file_exists($file)) {
$translator->addResource('yaml', $file, $app['locale']);
}
return $translator;
}));
}