PHPackages                             tyler36/localization - 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. tyler36/localization

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

tyler36/localization
====================

Localization middleware

2.2(4y ago)033MITPHP

Since Jun 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tyler36/localization)[ Packagist](https://packagist.org/packages/tyler36/localization)[ RSS](/packages/tyler36-localization/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

Introduction
============

[](#introduction)

This package is designed to simplify multi-locale applications. Simply add the required middleware and update your configuration.

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

[](#installation)

- Install package

```
composer require tyler36/localization

```

- Publish configuration Run the command below to publish the configuration file

```
php artisan vendor:publish --provider=tyler36/localization

```

- Add supported languages By default, only the current app locale is deemed valid. You can add additional languages to configuration file (`config/localization.php`). Can't see the file? Perhaps you forgot to publish it; see the above step. For a list of internationally recognized language codes, see [https://en.wikipedia.org/wiki/List\_of\_ISO\_639-1\_codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
- Apply middleware Add the desired middle to the `app/Http/Kernel.php` file in the required location. For more details, see the Laravel documentation ()

Middleware
----------

[](#middleware)

### Option 1: Header request

[](#option-1-header-request)

This middleware uses a request header to set the locale. By default, the query string is set to `X-localization` but can be changed through the config file. It's ideal for making request via javascript.

- Register `\Tyler36\Localization\Middleware\HeaderLocale::class`
- Set the header in via vanilla javascript or preferred javascript framework. For example, you can apply the header to all `Axios` request with the following:

```
// Set language to German ('de')
window.axios = axios;
window.axios.defaults.headers.common['X-localization'] = 'de';

```

Now, when you send a request to the endpoint Laravel will update the locale to match the setting, assuming it is configured as 'valid'.

### Option 2: Query String

[](#option-2-query-string)

This middleware is designed to use a query string.

- Register `\Tyler36\Localization\Middleware\QueryStringLocale::class`
- Add the query string to a URL. By default, the query string is set to `lang` but can be changed through the config file.

```
    // This will return the site with default locale
    https://cool-site.dev

    // This will return the site with locale to to German (de)
    https://cool-site.dev?lang=de

```

### Option 3: Member preference

[](#option-3-member-preference)

This middleware uses an attribute on the User model to set the locale. When a member is logged in, it check their saved locale and applies it.

- Register `\Tyler36\Localization\Middleware\MemberLocale::class`
- Create the attribute on User models By default, the query string is set to `locale` but can be changed through the config file.

```
    $table->string('locale', 2)->default(app()->getLocale());

```

### Option 4: Session

[](#option-4-session)

This middleware looks for a value in Laravel session.

- Register `\Tyler36\Localization\Middleware\SessionLocale::class`
- Create a route that saves the `session_key => locale` to the session By default, the `session_key` is set to `locale` but can be changed through the config file.

```
    $key = config('localization.session_key', 'locale');
    session([$key => request()->get($key)]);

```

or you could use the included controller by updating your route file

```
// routes/web.php
Route::get('/locale/{locale}', [
    'as' => 'localization.session',
    'uses' => '\Tyler36\Localization\Controller\LocaleController@session'
]);

// blade - create links
route('localization.session', [config('localization.session_key') => $locale]

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~240 days

Recently: every ~298 days

Total

6

Last Release

1697d ago

Major Versions

1.1 → 2.02018-08-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/c68f48588d57835c170cde02444307a450b98cfab07c9674094b881545c13b76?d=identicon)[tyler36](/maintainers/tyler36)

---

Top Contributors

[![s-hendrix-iqnet](https://avatars.githubusercontent.com/u/180614482?v=4)](https://github.com/s-hendrix-iqnet "s-hendrix-iqnet (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![tyler36](https://avatars.githubusercontent.com/u/7234392?v=4)](https://github.com/tyler36 "tyler36 (1 commits)")

---

Tags

i18nlaravellaravel-packagelocalizationmiddlewaremiddlewarelaravellanguagelocale

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/tyler36-localization/health.svg)

```
[![Health](https://phpackages.com/badges/tyler36-localization/health.svg)](https://phpackages.com/packages/tyler36-localization)
```

###  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)[awes-io/localization-helper

Package for convenient work with Laravel's localization features

3527.1k4](/packages/awes-io-localization-helper)[alkhatibdev/language-switcher

Laravel dynamic language switcher for web and api routes

124.2k](/packages/alkhatibdev-language-switcher)

PHPackages © 2026

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