We’re sorry but this documentation section is outdated. Please have that in mind when trying to use it. You can help us making documentation up to date via Sylius Github. Thank you!
In the Locale component there are three LocaleContexts defined:
It is a composite of different contexts available in your application, which are prioritized while being injected here (the one with highest priority is used).
It has the
getLocaleCode() method available, that helps you to get the currently used locale.
The LocaleProvider allows you to get all available locales.
<?php use Sylius\Component\Locale\Provider\LocaleProvider; $locales = new InMemoryRepository(); $localeProvider = new LocaleProvider($locales); $localeProvider->getAvailableLocalesCodes(); //Output will be a collection of available locales $localeProvider->isLocaleAvailable('en'); //It will check if that locale is enabled
For more detailed information go to Sylius API LocaleProvider.