PHPackages                             berthott/laravel-locale-middleware - 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. berthott/laravel-locale-middleware

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

berthott/laravel-locale-middleware
==================================

Laravel Helper for localizing API routes

3.0.0(3y ago)0718MITPHP

Since Feb 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/berthott/laravel-locale-middleware)[ Packagist](https://packagist.org/packages/berthott/laravel-locale-middleware)[ RSS](/packages/berthott-laravel-locale-middleware/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

[![test workflow](https://github.com/berthott/laravel-locale-middleware/actions/workflows/test.yml/badge.svg)](https://github.com/berthott/laravel-locale-middleware/actions/workflows/test.yml/badge.svg)

Laravel-Locale-Middleware
=========================

[](#laravel-locale-middleware)

A helper for localizing API routes. Easily add a locale option to all your API routes.

Installation
------------

[](#installation)

```
$ composer require berthott/laravel-locale-middleware
```

Basic Usage
-----------

[](#basic-usage)

- The package automatically adds a `locale` query parameter to all your API routes.
- Setting this `locale` query parameter will result in changing the Laravel locale for this specific request.
- In order for localization to work you'll need to provide the corresponding localization files. See [Laravel Lang](https://github.com/Laravel-Lang/lang) for a convenient way to install these.

Alias / Middleware Groups
-------------------------

[](#alias--middleware-groups)

- By default the middleware will be added to your `api` Middleware Group.
- You may set the `groups` option to an empty array, or an array of your custom Middleware Groups to add the middleware to.
- In addition you could add the route directly via it's alias `locale`.

Options
-------

[](#options)

To change the default options use

```
$ php artisan vendor:publish --provider="berthott\LocaleMiddleware\LocaleMiddlewareServiceProvider" --tag="config"
```

- `queryVariableName`: Specifies a custom name for the query parameter. Defaults to `locale`.
- `groups`: An array of middleware groups to add the locale middleware to. Defaults to `['api']`.

Compatibility
-------------

[](#compatibility)

Tested with Laravel 10.x.

License
-------

[](#license)

See [License File](license.md). Copyright © 2023 Jan Bladt.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~121 days

Total

4

Last Release

1232d ago

Major Versions

1.0.1 → 2.0.02022-03-23

2.0.0 → 3.0.02023-02-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3034025?v=4)[Jan Bladt](/maintainers/berthott)[@berthott](https://github.com/berthott)

---

Top Contributors

[![berthott](https://avatars.githubusercontent.com/u/3034025?v=4)](https://github.com/berthott "berthott (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/berthott-laravel-locale-middleware/health.svg)

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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