PHPackages                             aitor24/localizer - 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. aitor24/localizer

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

aitor24/localizer
=================

Pakcage to change easily default locale in laravel 5.4

1.4.6(8y ago)213.3k53MITPHPPHP &gt;=5.6.4CI failing

Since Dec 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/24aitor/Localizer)[ Packagist](https://packagist.org/packages/aitor24/localizer)[ RSS](/packages/aitor24-localizer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (33)Used By (3)

[![](https://camo.githubusercontent.com/1b37e1d83064e1172f93b45795d006b9681270304b3e9f44bfbc819f38001e39/68747470733a2f2f692e696d6775722e636f6d2f44374679344d422e706e67)](https://camo.githubusercontent.com/1b37e1d83064e1172f93b45795d006b9681270304b3e9f44bfbc819f38001e39/68747470733a2f2f692e696d6775722e636f6d2f44374679344d422e706e67)

Localizer
=========

[](#localizer)

 [![StyleCI](https://camo.githubusercontent.com/8c0b329527a5720dcba01085bc8a4cab9670254cfb54cf019c6992c10c4fada2/68747470733a2f2f7374796c6563692e696f2f7265706f732f37343939313236312f736869656c643f7374796c653d666c6174266272616e63683d6d6173746572)](https://styleci.io/repos/74991261) [![Version](https://camo.githubusercontent.com/9d72c6dece817dd2db83c029413e76cebded0e9bfd2d45e14faed89082d618cb/68747470733a2f2f706f7365722e707567782e6f72672f6169746f7232342f6c6f63616c697a65722f762f737461626c652e737667)](https://github.com/24aitor/Localizer/releases) [![Scrutinizer](https://camo.githubusercontent.com/8ca5cae3ba72190c390c6aaf26e2103f467d4a1b961b1abafa0d8c805210dbe6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f32346169746f722f4c6f63616c697a65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/24aitor/Localizer/?branch=master) [![Downloads](https://camo.githubusercontent.com/4366fd7fe141f32e08a8d22449aec7cc91d60ef910ca4dec7e3959759a61e8a9/68747470733a2f2f706f7365722e707567782e6f72672f6169746f7232342f6c6f63616c697a65722f642f746f74616c2e737667)](https://github.com/24aitor/Localizer) [![License](https://camo.githubusercontent.com/5147546736ff3951a713cc22f3974b1d9792fa87cea4dd4537fd0f7f047ff9c2/68747470733a2f2f706f7365722e707567782e6f72672f6169746f7232342f6c6f63616c697a65722f6c6963656e73652e737667)](https://raw.githubusercontent.com/24aitor/localizer/master/LICENSE)

What is Localizer?
------------------

[](#what-is-localizer)

Localizer is a laravel package to change easily locale on laravel projects.

It's so simple to use, once it's installed, your App locale will change only by passing routes into localizer middleare.

**Top features:**

- Change automatically app locale depending on user browser configuration
- Get language like 'Spanish' or 'English' from codes such as 'es' or 'en'.
- Store on users database table the user locale preference
- Restrict users to set languages you don't have translations

Getting Started
---------------

[](#getting-started)

### 1. Install it with composer

[](#1-install-it-with-composer)

Running the command below:

```
composer require aitor24/localizer

```

### 2. Register service provider

[](#2-register-service-provider)

Register the localizer service provider on `config/app.php`.

```
Aitor24\Localizer\LocalizerServiceProvider::class,
```

Remind to add alias to use Localizer functions comfortably.

```
'Localizer'   => Aitor24\Localizer\Facades\LocalizerFacade::class,
```

### 3. Publish config

[](#3-publish-config)

It will publish config file.

Running the command below:

```
php artisan vendor:publish --tag=localizer_config

```

#### 3.1 Publish languages

[](#31-publish-languages)

Also you can publish your languages to modify or add.

```
php artisan vendor:publish --tag=localizer_languages

```

### 4. Migrate

[](#4-migrate)

Publish migrations:

```
php artisan vendor:publish --tag=localizer_migrations

```

Running the command below:

```
php artisan migrate

```

### 5. Configure defalt values

[](#5-configure-defalt-values)

Default values can be modified also on `config/localizer.php`.

#### Keys

[](#keys)

- routes: Makes routes available.
- carbon: Sets carbon translator language.
- homeRoute: Make home route available.
- set\_auto\_lang: Sets language automatically depending on user's browser config
- default\_lang: Default language if set\_auto\_lang is false or user is attempting to set an unallowed language
- prefix: Prefix of routes URI to set locale,
- allowed\_langs: All allowed languages,
- middleware: default middleware to set locale,

Using Localizer
---------------

[](#using-localizer)

### Middleware

[](#middleware)

All routes in which you want to set language should be under the localizer's middleware to set at each request de App locale.

```
Route::group(['middleware' => 'localizer'], function () {

    // Here your routes

});
```

### Changing languages

[](#changing-languages)

- Via URL with return home: /lang/set/{locale}/home
- Via URL with return back: /lang/set/{locale}

**Tip:** */lang prefix will be changed on config*

Example languages view
----------------------

[](#example-languages-view)

Following there are a little code snippet of a view to select and set languages:

```
@foreach (Localizer::allowedLanguages() as $code => $value)
    {{ $value }}
@endforeach
```

API
---

[](#api)

### Localizer::allowedLanguages()

[](#localizerallowedlanguages)

Returns an array with \[$code =&gt; $language\] for all allowed languages of config.

### Localizer::addNames($codes)

[](#localizeraddnamescodes)

Get an array like \[$code =&gt; $language\] from an array of only $codes.

### Localizer::addCodes($lang)

[](#localizeraddcodeslang)

Get an array like \[$language =&gt; $code\] from an array of only $langs.

### Localizer::setRoute($code)

[](#localizersetroutecode)

*Used for modals or dropdowns*

Returns the url to set up language and return back.

Also if you prefer to use directly route() function you can use it as following code:

```
{{ route('localizer::setLocale', ['locale' => $code]) }}
```

### Localizer::setRouteHome($code)

[](#localizersetroutehomecode)

*Used for language selection views*

Returns the url to set language and return '/' *url('/')*

Also if you prefer to use directly route() function you can use it as following code:

```
{{ route('localizer::setLocaleHome', ['locale' => $code]) }}
```

### Localizer::getLanguage($code = App::getLocale())

[](#localizergetlanguagecode--appgetlocale)

Returns the language name of $code if specified or the current language setted if not.

**Tip:** *Use App::getLocale() to get the current locale*

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 96.5% 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 ~14 days

Recently: every ~22 days

Total

26

Last Release

3073d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a56e20e7af7971bdf153b60a506c54be8e2bbeb3a7cd15e1ac04247829299040?d=identicon)[24aitor](/maintainers/24aitor)

---

Top Contributors

[![24aitor](https://avatars.githubusercontent.com/u/20477883?v=4)](https://github.com/24aitor "24aitor (111 commits)")[![denisdulici](https://avatars.githubusercontent.com/u/5254835?v=4)](https://github.com/denisdulici "denisdulici (2 commits)")[![ConsoleTVs](https://avatars.githubusercontent.com/u/6124435?v=4)](https://github.com/ConsoleTVs "ConsoleTVs (1 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (1 commits)")

---

Tags

languagelocale

### Embed Badge

![Health badge](/badges/aitor24-localizer/health.svg)

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

###  Alternatives

[mcamara/laravel-localization

Easy localization for Laravel

3.5k9.1M112](/packages/mcamara-laravel-localization)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.3k](/packages/typicms-base)[vemcogroup/laravel-translation

Translation package for Laravel to scan for localisations and up/download to poeditor

135304.0k2](/packages/vemcogroup-laravel-translation)

PHPackages © 2026

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