diff --git a/config/localizer.php b/config/localizer.php index 3fab7fe..46a7634 100644 --- a/config/localizer.php +++ b/config/localizer.php @@ -13,6 +13,7 @@ */ 'detectors' => [ CodeZero\Localizer\Detectors\UrlDetector::class, + CodeZero\Localizer\Detectors\UserDetector::class, CodeZero\Localizer\Detectors\SessionDetector::class, CodeZero\Localizer\Detectors\CookieDetector::class, CodeZero\Localizer\Detectors\BrowserDetector::class, @@ -34,6 +35,12 @@ */ 'url-segment' => 1, + /** + * The attribute on the user model that holds the locale, + * when using the UserDetector. + */ + 'user-attribute' => 'locale', + /** * The session key that holds the locale, * when using the SessionDetector and SessionStore. diff --git a/src/Detectors/UserDetector.php b/src/Detectors/UserDetector.php new file mode 100644 index 0000000..6d363b7 --- /dev/null +++ b/src/Detectors/UserDetector.php @@ -0,0 +1,27 @@ +getAttributeValue($attribute); + } +}