Comments (3)
Hello,
I don't know why the invoke method isn't used automatically, I've seen this come up before.
Your second example with the array brackets is missing an S in Controllers in the namespace.
Will it work like that?
EDIT:
In your first example, it seems that a default namespace is applied.
Can't remember if you can override this just by importing the controller at the top:
use \CodeZero\LocalizedRoutes\Controllers\FallbackController;
Route::fallback(FallbackController::class)
->middleware(\CodeZero\LocalizedRoutes\Middleware\SetLocale::class);
from laravel-localized-routes.
Adding the missing S fixed the issue. Thanks
By the way, I have a question.
How can I configure it to flow like this
A user enters the website, e.g., example.com
If the user's browser's language is set to English, he is redirected to /en. If French, he is redirected to /fr
from laravel-localized-routes.
The middleware will look for a locale in the browser on a first visit (unless there is a valid locale in the URL).
You already added the FallbackController
, so you only need to set the redirect_to_localized_urls
config option to true
to auto redirect to the found locale.
More info:
https://github.com/codezero-be/laravel-localized-routes#detectors
https://github.com/codezero-be/laravel-localized-routes#-automatically-redirect-to-localized-urls
If you need more control, you can just use app()->getLocale()
in a route action and redirect manually based on that, or basically do anything you need with it..
from laravel-localized-routes.
Related Issues (20)
- How to use with Laravel Route Attributes
- Call to undefined method Composer\Util\Platform::getCwd() HOT 5
- Problem using livewire HOT 11
- Inertia js blank page HOT 2
- Fallback Controller Invalid Route Action HOT 4
- Authentication Breaks on Localized Routes HOT 5
- Route not defined. HOT 3
- * Use Localizer to Detect and Set the Locale HOT 1
- Resource routes HOT 2
- composer-include-files dependency breaks autoload-dev files HOT 3
- How to override route helper? HOT 4
- Share routes with front frameworks like Inertia/VueJS HOT 4
- What's the best way to deal with more complex locales like 'ch-fr'? HOT 1
- Subdomain localized urls HOT 6
- How to remove route parameters? HOT 5
- auto redirect HOT 5
- Redirect request with default locale to omitted locale url HOT 4
- Locale Switcher HOT 2
- Call to a member function getAction() on null HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-localized-routes.