Make sure all locale JS files are flushed

Even when no language packs are enabled, a forum-en-xxx.js (or whatever the default locale is) file is still generated because other extensions may contain translations. But when enabling the English language pack, since no locales are registered with the LocaleManager, that file doesn't get flushed and therefore doesn't get regenerated with the English translations. This fix always registers the default locale with the LocaleManager so that's not the case.
This commit is contained in:
Toby Zerner 2015-11-04 09:22:09 +10:30
parent 30856a8e2b
commit c9a878d49c

View File

@ -25,6 +25,8 @@ class LocaleServiceProvider extends AbstractServiceProvider
{
$locales = $this->app->make('flarum.localeManager');
$locales->addLocale($this->getDefaultLocale(), 'Default');
$events->fire(new ConfigureLocales($locales));
}
@ -37,9 +39,7 @@ class LocaleServiceProvider extends AbstractServiceProvider
$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';
$defaultLocale = $this->getDefaultLocale();
$translator = new Translator($defaultLocale, new MessageSelector());
$translator->setFallbackLocales([$defaultLocale, 'en']);
@ -50,4 +50,11 @@ class LocaleServiceProvider extends AbstractServiceProvider
$this->app->alias('translator', 'Symfony\Component\Translation\Translator');
$this->app->alias('translator', 'Symfony\Component\Translation\TranslatorInterface');
}
private function getDefaultLocale()
{
return $this->app->isInstalled() && $this->app->isUpToDate()
? $this->app->make('flarum.settings')->get('default_locale', 'en')
: 'en';
}
}