Adding a language selector is crucial to any multilingual application. In this practical example, we'll add a language selector to our navigation bar:
In this first example, we will define the language from the URL segment, like /en/about
or /es/register
.
Setup
Here's our plan to set up a language selector:
- Configuration: add a language list to the config - this will be used to display the language selector
- Middleware: Add a Middleware to handle language change and URL redirection
- Routes: Modify Routes to use the Middleware
- Views: Add a language selector to our Views
- Redirects: Modify our redirects for authentication
Let's start with the configuration:...