1
0
mirror of https://github.com/flarum/core.git synced 2025-10-28 14:06:30 +01:00

fixed alias/reference loading for translation strings

This commit is contained in:
Daniel Klabbers
2017-11-27 10:35:57 +01:00
parent e2d61d1aeb
commit 7b2663e0bc
3 changed files with 8 additions and 11 deletions

View File

@@ -16,7 +16,6 @@ use Flarum\Foundation\AbstractServiceProvider;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorInterface;
class LocaleServiceProvider extends AbstractServiceProvider
@@ -42,10 +41,8 @@ class LocaleServiceProvider extends AbstractServiceProvider
$this->app->alias(LocaleManager::class, 'flarum.localeManager');
$this->app->singleton('translator', function () {
$defaultLocale = $this->getDefaultLocale();
$translator = new Translator($defaultLocale, new MessageSelector());
$translator->setFallbackLocales([$defaultLocale, 'en']);
$translator = new Translator($this->getDefaultLocale(), new MessageSelector());
$translator->setFallbackLocales(['en']);
$translator->addLoader('prefixed_yaml', new PrefixedYamlFileLoader());
return $translator;
@@ -55,7 +52,7 @@ class LocaleServiceProvider extends AbstractServiceProvider
$this->app->alias('translator', TranslatorContract::class);
}
private function getDefaultLocale()
private function getDefaultLocale(): string
{
return $this->app->isInstalled() && $this->app->isUpToDate()
? $this->app->make('flarum.settings')->get('default_locale', 'en')