Overview
Learn how to resolve the visitor's preferred locale.
This interface abstracts how the visitor’s preferred locale is determined.
The framework integrations, such as the Laravel, Symfony, and Drupal SDKs, consume it to serve content in the visitor’s language. They resolve the locale from the framework automatically, but you can implement this interface to provide a custom source.
Usage
Implement the interface to resolve the locale from your application:
12345678910
<?phpuse Croct\Plug\LocaleResolver;
final class SessionLocaleResolver implements LocaleResolver{ public function getLocale(): ?string { return $_SESSION['locale'] ?? null; }}