public function detectLocaleFromLocaleTag($localeIdentifier) { try { return $this->detectLocaleFromTemplateLocale(new Locale($localeIdentifier)); } catch (Exception\InvalidLocaleIdentifierException $exception) { return $this->localizationService->getConfiguration()->getDefaultLocale(); } }
/** * @test * @dataProvider sampleLocaleIdentifiers */ public function detectingBestMatchingLocaleFromLocaleIdentifierWorksCorrectly($localeIdentifier, $expectedResult) { $locale = $this->detector->detectLocaleFromLocaleTag($localeIdentifier); $this->assertEquals($expectedResult, $locale); }