Giter Club home page Giter Club logo

Comments (3)

ivanvermeyen avatar ivanvermeyen commented on June 12, 2024

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.

UtkuDalmaz avatar UtkuDalmaz commented on June 12, 2024

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.

ivanvermeyen avatar ivanvermeyen commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.