Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Change Behavior #3

Open
rolandstarke opened this issue Feb 28, 2019 · 0 comments
Open

Change Behavior #3

rolandstarke opened this issue Feb 28, 2019 · 0 comments

Comments

@rolandstarke
Copy link

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 is false 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant