Skip to content
Advertisement

Laravel localization in routes without prefix

I have a Laravel app in 9 difference languages:

JavaScript

I’m trying to set up localized URL’s like:

JavaScript

All content on the website is displayed in the correct language but routing returns 404 pages except for default fallback language.

My web.php

JavaScript

My locale middleware:

JavaScript

Using the fallback language URLs in production i’m able to get the content localized but URL’s in the web.php won’t allow translation. I don’t want to have prefix in URL’s since the different locales are set by domain instead.

Advertisement

Answer

Okay so i took a small break and figured out a possible solution which seems to be working perfectly.

JavaScript

Let me know if this has any potential breaks, but for me it’s working.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement