Skip to content

Commit 7ff72be

Browse files
committed
Add a constructor for FallbackLocaleProvider
1 parent 7ba97ad commit 7ff72be

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Symfony/Component/Translation/FallbackLocaleProvider.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Translation;
1313

14+
use Symfony\Component\Translation\Exception\InvalidArgumentException;
15+
1416
/**
1517
* Derives fallback locales based on ICU parent locale information, by shortening locale
1618
* sub tags and ultimately by going through a list of configured fallback locales.
@@ -26,6 +28,16 @@ class FallbackLocaleProvider implements FallbackLocaleProviderInterface
2628

2729
private array $parentLocales;
2830

31+
/**
32+
* @param string[] $locales
33+
*
34+
* @throws InvalidArgumentException If a locale contains invalid characters
35+
*/
36+
public function __construct(array $locales = [])
37+
{
38+
$this->setFallbackLocales($locales);
39+
}
40+
2941
public function setFallbackLocales(array $locales): void
3042
{
3143
foreach ($locales as $locale) {

0 commit comments

Comments
 (0)