/** * {@inheritdoc} */ public function register() { $this->app->singleton('Flarum\\Locale\\LocaleManager'); $this->app->alias('Flarum\\Locale\\LocaleManager', 'flarum.localeManager'); $this->app->singleton('translator', function () { $defaultLocale = $this->getDefaultLocale(); $translator = new Translator($defaultLocale, new MessageSelector()); $translator->setFallbackLocales([$defaultLocale, 'en']); $translator->addLoader('yaml', new YamlFileLoader()); return $translator; }); $this->app->alias('translator', 'Symfony\\Component\\Translation\\Translator'); $this->app->alias('translator', 'Symfony\\Component\\Translation\\TranslatorInterface'); }
/** * {@inheritdoc} */ public function register() { $this->app->singleton('Flarum\\Locale\\LocaleManager'); $this->app->alias('Flarum\\Locale\\LocaleManager', 'flarum.localeManager'); $this->app->singleton('translator', function () { $defaultLocale = $this->app->isInstalled() && $this->app->isUpToDate() ? $this->app->make('flarum.settings')->get('default_locale', 'en') : 'en'; $translator = new Translator($defaultLocale, new MessageSelector()); $translator->setFallbackLocales([$defaultLocale, 'en']); $translator->addLoader('yaml', new YamlFileLoader()); return $translator; }); $this->app->alias('translator', 'Symfony\\Component\\Translation\\Translator'); $this->app->alias('translator', 'Symfony\\Component\\Translation\\TranslatorInterface'); }