getLocale
Learn how to provide the visitor's preferred locale.
An implementation must return the visitor’s preferred locale, or null when none can be determined.
Signature
This method has the following signature:
public function getLocale(): ?stringThis method returns the visitor’s preferred locale, or null when none can be determined.
Example
This example resolves the locale from the application’s localization service:
1234567891011121314151617
<?phpuse Croct\Plug\LocaleResolver;
final class AppLocaleResolver implements LocaleResolver{ private Translator $translator;
public function __construct(Translator $translator) { $this->translator = $translator; }
public function getLocale(): ?string { return $this->translator->getLocale(); }}