localized-routes.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. $localeSequence = preg_replace('/\s+/', '', explode(',', env('LOCALE_SEQUENCE')));
  3. $localeList = collect($localeSequence)->map(function ($country) {
  4. return strtolower(explode('_', $country)[0]);
  5. })->toArray();
  6. $locale = $localeList[0];
  7. return [
  8. /**
  9. * The locales you wish to support.
  10. */
  11. 'supported-locales' => $localeList,
  12. /**
  13. * The fallback locale to use when a provided locale is not supported.
  14. */
  15. 'fallback_locale' => $locale,
  16. /**
  17. * If you have a main locale and don't want
  18. * to prefix it in the URL, specify it here.
  19. *
  20. * 'omit_url_prefix_for_locale' => 'en',
  21. */
  22. // 'omit_url_prefix_for_locale' => $locale,
  23. 'omit_url_prefix_for_locale' => null,
  24. /**
  25. * Set this option to true if you want to redirect
  26. * unlocalized URL's to their localized version.
  27. * You need to register the fallback route for this to work.
  28. */
  29. 'redirect_to_localized_urls' => true,
  30. /**
  31. * The status code when redirecting to localized URL's.
  32. * 301 - permanently
  33. * 302 - temporary
  34. */
  35. 'redirect_status_code' => 301,
  36. /**
  37. * Set your custom 404 view.
  38. * This view is localized.
  39. * If the view does not exist, a normal 404 will be thrown.
  40. * You need to register the fallback route for this to work.
  41. */
  42. '404_view' => 'errors.404',
  43. /**
  44. * If you want to automatically set the locale
  45. * for localized routes set this to true.
  46. */
  47. 'use_locale_middleware' => true,
  48. /**
  49. * If true, this package will use 'codezero/laravel-localizer'
  50. * to detect and set the preferred supported locale.
  51. *
  52. * For non-localized routes, it will look for a locale in the URL,
  53. * in the session, in a cookie, in the browser or in the app config.
  54. * This can be very useful if you have a generic home page.
  55. *
  56. * If a locale is detected, it will be stored in the session,
  57. * in a cookie and as the app locale.
  58. *
  59. * If you disable this option, only localized routes will have a locale
  60. * and only the app locale will be set (so not in the session or cookie).
  61. *
  62. * You can publish its config file and tweak it for your needs.
  63. * This package will only override its 'supported-locales' option
  64. * with the 'supported-locales' option in this file.
  65. *
  66. * For more info, visit:
  67. * https://github.com/codezero-be/laravel-localizer
  68. *
  69. * This option only has effect if you use the SetLocale middleware.
  70. */
  71. 'use_localizer' => true,
  72. /**
  73. * Map application locale to a custom route prefix.
  74. *
  75. * 'custom_prefixes' => [
  76. * 'en' => 'english',
  77. * 'nl' => 'dutch',
  78. * ]
  79. */
  80. 'custom_prefixes' => [],
  81. ];