From c9a878d49cd680cca3cbefcc9348bab896f4ee00 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Wed, 4 Nov 2015 09:22:09 +1030 Subject: [PATCH] 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. --- src/Locale/LocaleServiceProvider.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Locale/LocaleServiceProvider.php b/src/Locale/LocaleServiceProvider.php index 1e8546d32..019296259 100644 --- a/src/Locale/LocaleServiceProvider.php +++ b/src/Locale/LocaleServiceProvider.php @@ -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'; + } }