josiasmontag / laravel-localization

Laravel Localization Package
MIT License
21 stars 5 forks source link

Question #2

Closed bsh closed 6 years ago

bsh commented 6 years ago

Hi! Is is possible to set the locale by language prefix? For example /de/home set the locale automatically.

josiasmontag commented 6 years ago

This should be already the case.

bsh commented 6 years ago

Hi!

  1. http://localhost:8000/hu/test?hl=hu - Locale: hu - ok
  2. go to: http://localhost:8000/hu/test - Locale: hu - ok
  3. go to: http://localhost:8000/pl/test - Locale: hu - I need pl
  4. go to: http://localhost:8000/test - Locale: hu - I need en

Is this possible?

josiasmontag commented 6 years ago

Already happening, see: https://github.com/josiasmontag/laravel-localization/blob/master/tests/MiddlewareTest.php#L33

Please note that per default it automatically detects the locale via Accept-Language header and cookie. This is preferred over the URL prefix. You can disable this in the config.

bsh commented 6 years ago

Ok. I've got it. Thank you for your help.