diff --git a/src/Container/Services.php b/src/Container/Services.php index 738bc7e9..c2785f05 100644 --- a/src/Container/Services.php +++ b/src/Container/Services.php @@ -513,12 +513,8 @@ public static function toolbar(?stdClass $config = null, bool $shared = true): T */ public static function translator(?string $locale = null, bool $shared = true): Translate { - if (($locale === null || $locale === '' || $locale === '0') && empty($locale = static::$instances[Translate::class . 'locale'] ?? null)) { - $config = static::config()->get('app'); - if (($locale = static::negotiator()->language($config['supported_locales'])) === '' || ($locale = static::negotiator()->language($config['supported_locales'])) === '0') { - $locale = $config['language']; - } - static::$instances[Translate::class . 'locale'] = $locale; + if (null === $locale || $locale === '' || $locale === '0') { + $locale = static::request()->getLocale(); } if (true === $shared && isset(static::$instances[Translate::class])) { diff --git a/src/Http/ServerRequest.php b/src/Http/ServerRequest.php index e7407e43..af9ffa25 100644 --- a/src/Http/ServerRequest.php +++ b/src/Http/ServerRequest.php @@ -1827,11 +1827,10 @@ public function withLocale(string $locale): static */ public function getLocale(): string { - $locale = $this->getAttribute('locale'); - if (empty($locale)) { + if (empty($locale = $this->getAttribute('locale'))) { $locale = $this->getAttribute('lang'); } - return $locale ?? Services::translator()->getLocale(); + return $locale ?? config('app.language'); } }