From eff5e3c8e6627314937841612fb75042c2ce7e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Wed, 3 Apr 2024 09:20:51 +0200 Subject: [PATCH] [Translation] Silence error when intl not loaded Fix issue 1505 from Symfony Demo https://github.com/symfony/demo/issues/1505 --- src/Symfony/Component/Translation/LocaleSwitcher.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Translation/LocaleSwitcher.php b/src/Symfony/Component/Translation/LocaleSwitcher.php index c07809c58cbcc..4950a56bbb682 100644 --- a/src/Symfony/Component/Translation/LocaleSwitcher.php +++ b/src/Symfony/Component/Translation/LocaleSwitcher.php @@ -34,9 +34,14 @@ public function __construct( public function setLocale(string $locale): void { - if (class_exists(\Locale::class)) { - \Locale::setDefault($locale); + // Silently ignore if the intl extension is not loaded + try { + if (class_exists(\Locale::class, false)) { + \Locale::setDefault($locale); + } + } catch (\Exception) { } + $this->locale = $locale; $this->requestContext?->setParameter('_locale', $locale); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy