PHPackages                             lykegenes/laravel-locale-switcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. lykegenes/laravel-locale-switcher

ActiveLibrary[Localization &amp; i18n](/categories/localization)

lykegenes/laravel-locale-switcher
=================================

A Laravel locale switcher Middleware

9.0.0(3y ago)61.2k1MITPHPCI failing

Since Jul 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/patricksamson/laravel-locale-switcher)[ Packagist](https://packagist.org/packages/lykegenes/laravel-locale-switcher)[ Docs](https://github.com/patricksamson/laravel-locale-switcher)[ RSS](/packages/lykegenes-laravel-locale-switcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (23)Used By (0)

Laravel Locale Switcher
=======================

[](#laravel-locale-switcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3c5032310c96bfb9bb5a51afcf11caa83cc5c5afcdbd345d64bd9b663f29180f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c796b6567656e65732f6c61726176656c2d6c6f63616c652d73776974636865722e737667)](https://packagist.org/packages/lykegenes/laravel-locale-switcher)[![Software License](https://camo.githubusercontent.com/6b5487ecb40a662f9825f65b15a6d76d12cb362d5c8a7625430373fe8662dc0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7061747269636b73616d736f6e2f6c61726176656c2d6c6f63616c652d73776974636865722e737667)](LICENSE.md)[![Build Status](https://github.com/patricksamson/laravel-locale-switcher/workflows/Run%20Tests/badge.svg?branch=9.x)](https://github.com/patricksamson/laravel-locale-switcher/workflows/Run%20Tests/badge.svg?branch=9.x)[![Total Downloads](https://camo.githubusercontent.com/5bee4a8bedb3197fd0d186c2914287077ef137fc0aeb09cdd386c0689a79fbd1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c796b6567656e65732f6c61726176656c2d6c6f63616c652d73776974636865722e737667)](https://packagist.org/packages/lykegenes/laravel-locale-switcher)

A Simple Laravel middleware to easily load and switch the user's locale.

Version Compatibility
---------------------

[](#version-compatibility)

LaravelLaravel Locale Switcher5.x1.5.x6.x6.x7.x7.x8.x8.x9.x9.xInstall
-------

[](#install)

Via Composer

```
composer require lykegenes/laravel-locale-switcher
```

Then, add this to your Service Providers (It should be done automa) :

```
Lykegenes\LocaleSwitcher\ServiceProvider::class,
```

and add this Alias \[Optional\]

```
'LocaleSwitcher' => Lykegenes\LocaleSwitcher\Facades\LocaleSwitcher::class,
```

Finally, you will need to register this Middleware either in your `Kernel.php` or directly in your routes. This way, you can control which routes will have automatic locale detection (Web pages) or not (your API). Make sure this middleware is placed **after** any Session or Cookie related middlewares from the framework.

```
\Lykegenes\LocaleSwitcher\Middleware\SwitchLocaleMiddleware::class,
```

Optionally, you can publish and edit the configuration file :

```
php artisan vendor:publish --provider="Lykegenes\LocaleSwitcher\ServiceProvider" --tag=config
```

Usage
-----

[](#usage)

To change the locale, simply add **"locale"** to the route parameters. It works for all your routes. Some examples :

```
http://my-app.com/?locale=en
http://my-app.com/some/sub/route?locale=fr
http://my-app.com/some/sub/route?locale=es&otherParam=value

```

This will store the locale in the user's session, and set it as the current locale everytime the user requests a page.

You can build the routes with the included helpers. The URLs will be generated using the current locale.

```
$url = action_localized('SomeController@someFunction', ['your' => 'parameters']);
$url = route_localized('someNamedRoute', ['your' => 'parameters']);
```

To build a URL to the same page, but with a different locale, use the `switch_locale()` helper.

```
$url = switch_locale('fr'); // URL of the French version of the current page.
```

You can easily generate a dropdown using the [laravelcollective/html](https://github.com/LaravelCollective/html) package :

```
HTML::ul(LocaleSwitcher::getEnabledLocales());
```

Credits
-------

[](#credits)

- [Patrick Samson](https://github.com/patricksamson)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 99% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~166 days

Recently: every ~187 days

Total

17

Last Release

1300d ago

Major Versions

1.5.0 → 2.0.02020-01-13

2.0.0 → 6.0.02020-10-07

6.0.0 → 7.0.02020-10-07

7.0.0 → 8.0.02020-10-07

6.x-dev → 9.0.02022-06-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/00961241bfba1f54c7c590fad6b3f8ece27d3783727f6371f69b9cd560df93ab?d=identicon)[Lykegenes](/maintainers/Lykegenes)

---

Top Contributors

[![patricksamson](https://avatars.githubusercontent.com/u/1416027?v=4)](https://github.com/patricksamson "patricksamson (104 commits)")[![nmiyazaki-chapleau](https://avatars.githubusercontent.com/u/104367522?v=4)](https://github.com/nmiyazaki-chapleau "nmiyazaki-chapleau (1 commits)")

---

Tags

hacktoberfesti18nlaravellocalepackagemiddlewarelaravellocaleswitcher

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lykegenes-laravel-locale-switcher/health.svg)

```
[![Health](https://phpackages.com/badges/lykegenes-laravel-locale-switcher/health.svg)](https://phpackages.com/packages/lykegenes-laravel-locale-switcher)
```

###  Alternatives

[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains or route prefixes.

109554.8k3](/packages/vluzrmos-language-detector)[opgginc/codezero-laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

2770.1k1](/packages/opgginc-codezero-laravel-localized-routes)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5514.4k1](/packages/longman-laravel-multilang)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)[eolica/nova-locale-switcher

A simple locale switcher for Nova without any concrete localization implementation

1328.1k](/packages/eolica-nova-locale-switcher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
