Mikegk's avatar

Localized routes like .../en/

Hi guys,

Im searching for a solution to enable routing like: MyDomain.com/en/home MyDomain.com/de/home

I found this one here: https://laracasts.com/discuss/channels/laravel/how-to-prefixing-in-routes-for-localization

But, there's a function called array_prepend, that I do not know or found in a current Laravel (8) Version (it's also not a native PHP function though).

Thanks for help :).

0 likes
2 replies
STEREOH's avatar
STEREOH
Best Answer
Level 18

Do you absolutelly want to code the localization yourself ?

If not I'd recomend a package like this one : https://github.com/codezero-be/laravel-localized-routes

If you want to use the method posted in the thread you linked , maybe try to replace array_prepend with array_unshift ( it basically prepends the array with the passed value, so I think it would be ok )

1 like
Richard-pro's avatar

array_prepend isn’t built‑in — use Illuminate\Support\Arr::prepend() or array_unshift() instead.

Please or to participate in this conversation.