laravel-localization
laravel-localization copied to clipboard
Change Behavior
Hey ty for the library, maybe some Ideas.
When using the following config I would suggest this changes:
localization.php
'locales' => [
'en' => ['name' => 'English', 'script' => 'Latn', 'native' => 'English', 'regional' => 'en_GB'],
'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE'],
],
'hide_default_locale_in_url' => false,
'locale_query_parameter' => null,
'redirect_to_localized_route' => true,
'detect_via_http_header' => true,
'detect_via_session' => true,
Route | Behavior Right now | Wanted Behavior |
---|---|---|
/ | 404 NOT FOUND | 302 Redirect -> check session -> check header -> default = /en/ |
/en/ | show english content | show english content |
/de/ | redirects to english (if no redirect is enabled then the english content is served under /de/) | show german content |
-
Always prioritize url over session and http header, only use them when the language is not clear from the url.
-
If
hide_default_locale_in_url
isfalse
register an additional url that redirects to the right url (or if no redirect is enabled, serves the content based on session -> header -> default)
Examples (redirect)
http://php.net/manual/function.echo.php -> http://php.net/manual/en/function.echo.php (based on header first time probably and after that cookie)
https://developer.mozilla.org/docs/Web/HTML/Element/a -> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Example (no redirect):
https://support.google.com/webmasters/answer/93633 shows language based on google account or headers probably https://support.google.com/webmasters/answer/93633?hl=de shows german content https://support.google.com/webmasters/answer/93633?hl=en shows english content