Skip to content

Commit 44eda81

Browse files
committed
[Translation] Silence error when intl not loaded
Fix issue 1505 from Symfony Demo symfony/demo#1505
1 parent bce6a5a commit 44eda81

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

LocaleSwitcher.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ public function __construct(
3434

3535
public function setLocale(string $locale): void
3636
{
37-
if (class_exists(\Locale::class)) {
38-
\Locale::setDefault($locale);
37+
// Silently ignore if the intl extension is not loaded
38+
try {
39+
if (class_exists(\Locale::class, false)) {
40+
\Locale::setDefault($locale);
41+
}
42+
} catch (\Exception) {
3943
}
44+
4045
$this->locale = $locale;
4146
$this->requestContext?->setParameter('_locale', $locale);
4247

0 commit comments

Comments
 (0)