mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 13:36:10 +08:00
fixed alias/reference loading for translation strings
This commit is contained in:
parent
4c94ad5df4
commit
386416c017
|
@ -11,12 +11,13 @@
|
|||
|
||||
namespace Flarum\Locale;
|
||||
|
||||
use Symfony\Component\Translation\Translator as SymfonyTranslator;
|
||||
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
||||
class LocaleManager
|
||||
{
|
||||
/**
|
||||
* @var SymfonyTranslator
|
||||
* @var Translator
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
|
@ -27,9 +28,9 @@ class LocaleManager
|
|||
protected $css = [];
|
||||
|
||||
/**
|
||||
* @param SymfonyTranslator $translator
|
||||
* @param Translator $translator
|
||||
*/
|
||||
public function __construct(SymfonyTranslator $translator)
|
||||
public function __construct(Translator $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -29,7 +29,6 @@ class Translator extends BaseTranslator implements TranslatorContract
|
|||
} else {
|
||||
$this->assertValidLocale($locale);
|
||||
}
|
||||
|
||||
$parse = ! isset($this->catalogues[$locale]);
|
||||
|
||||
$catalogue = parent::getCatalogue($locale);
|
||||
|
|
Loading…
Reference in New Issue
Block a user