PHPackages                             luizjr/language - 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. luizjr/language

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

luizjr/language
===============

Language switcher package for Laravel.

v1.0.6(6y ago)1878MITPHPPHP &gt;=5.6.4

Since May 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/luizjr/language)[ Packagist](https://packagist.org/packages/luizjr/language)[ RSS](/packages/luizjr-language/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Language switcher package for Laravel.
======================================

[](#language-switcher-package-for-laravel)

[![Version](https://camo.githubusercontent.com/beb4a233223f64cc37464e73682796d8a39e14c5a6e1a8a644d1b8755bff3485/68747470733a2f2f706f7365722e707567782e6f72672f4c75697a4a722f6c616e67756167652f762f737461626c652e737667)](https://github.com/LuizJr/language/releases)[![Downloads](https://camo.githubusercontent.com/80edca6fe259fd1d0fb01568a4d57a6024c109086f72dfebb0f8aec3c52f9247/68747470733a2f2f706f7365722e707567782e6f72672f4c75697a4a722f6c616e67756167652f642f746f74616c2e737667)](https://github.com/LuizJr/language)[![StyleCI](https://camo.githubusercontent.com/bafe6dae8d6d2e40ea71b654203e1ee3a0671ac59cc3d49057523e69afcee899/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138383538383339352f736869656c643f7374796c653d666c6174266272616e63683d6d6173746572)](https://github.styleci.io/repos/188588395)[![License](https://camo.githubusercontent.com/f00c33b05fd9c1f7bf4cea9d6be5ff5fc7c8118af4f8364394d76159fdda43cc/68747470733a2f2f706f7365722e707567782e6f72672f4c75697a4a722f6c616e67756167652f6c6963656e73652e737667)](LICENSE.md)

This package allows switching locale easily on Laravel projects. It's so simple to use, once it's installed, your App locale will change only by passing routes into SetLanguage middleware.

**Top features:**

- Change automatically app locale depending on user browser configuration
- Language flags built-in for easy implementation
- Get language name like 'English' or 'Español' from codes such as 'en' or 'es'
- Option to choose short (en) or long (en-GB) language code
- Store locale on users table
- Restrict users to set languages you don't have translations
- Helper functions for clean, simple and easy to read API
- Supports Carbon and Date packages

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

[](#getting-started)

### 1. Install

[](#1-install)

Run the following command:

```
composer require luizjr/language

```

### 2. Register (for Laravel &lt; 5.5)

[](#2-register-for-laravel--55)

Register the service provider in `config/app.php`

```
LuizJr\Language\Provider::class,
```

Add alias if you want to use the facade.

```
'Language'   => LuizJr\Language\Facade::class,
```

### 3. Publish

[](#3-publish)

Publish config, migration and blade files.

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

```

### 4. Migrate

[](#4-migrate)

Add locale column to users table:

```
php artisan migrate

```

### 5. Configure

[](#5-configure)

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

#### Keys

[](#keys)

- route: Makes route available
- carbon: Sets briannesbitt/carbon translator language
- date: Sets jenssegers/date translator language
- home: Make home route available
- auto: Sets language automatically depending on user's browser config
- prefix: Prefix of routes URI to set locale
- middleware: default middleware to set locale
- controller: default controller to handle locale
- flags: Settings such as width, class etc for flags
- mode: The language code and name mode
- allowed: Allowed language codes
- all: Available language names and codes

Usage
-----

[](#usage)

### Middleware

[](#middleware)

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

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

    // Here your routes

});
```

### URL

[](#url)

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

**Tip:** */languages prefix can be changed from `config/language.php`*

Methods
-------

[](#methods)

### language()-&gt;allowed()

[](#language-allowed)

Returns an array with `[$code => $name]` for all allowed languages of config. Example usage on blade:

```
@foreach (language()->allowed() as $code => $name)
    {{ $name }}
@endforeach
```

### language()-&gt;flags()

[](#language-flags)

Returns an output with flags for all allowed languages of config. Output can be changed from `resources/views/vendor/language` folder

### language()-&gt;flag()

[](#language-flag)

Returns the flag of the current locale. Output can be changed from `resources/views/vendor/language` folder

### language()-&gt;names($codes = null)

[](#language-namescodes--null)

Get an array like `[$code => $name]` from an array of only $codes.

### language()-&gt;codes($langs = null)

[](#language-codeslangs--null)

Get an array like `[$name => $code]` from an array of only $langs.

### language()-&gt;back($code)

[](#language-backcode)

Returns the URL to set up language and return back: `back()`

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

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

### language()-&gt;home($code)

[](#language-homecode)

Returns the URL to set language and return to home: `url('/')`

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

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

### language()-&gt;getName($code = 'default')

[](#language-getnamecode--default)

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

**Tip:** *Use app()-&gt;getLocale() to get the current locale*

### language()-&gt;getCode($name = 'default')

[](#language-getcodename--default)

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

### language()-&gt;getShortCode($long = 'default')

[](#language-getshortcodelong--default)

Returns the language short code of `$long` if specified or the current language set if not.

Changelog
---------

[](#changelog)

Please see [Releases](../../releases) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Luiz Jr](https://github.com/luizjr)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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 ~32 days

Recently: every ~21 days

Total

6

Last Release

2432d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1474563?v=4)[Luiz Junior](/maintainers/luizjr)[@luizjr](https://github.com/luizjr)

---

Top Contributors

[![luizjr](https://avatars.githubusercontent.com/u/1474563?v=4)](https://github.com/luizjr "luizjr (9 commits)")[![ImgBotApp](https://avatars.githubusercontent.com/u/31427850?v=4)](https://github.com/ImgBotApp "ImgBotApp (1 commits)")

---

Tags

laravellanguageswitcher

### Embed Badge

![Health badge](/badges/luizjr-language/health.svg)

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

###  Alternatives

[akaunting/laravel-language

Language switcher package for Laravel

223301.2k1](/packages/akaunting-laravel-language)[typicms/base

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

1.6k20.4k](/packages/typicms-base)[josiasmontag/laravel-redis-mock

This Laravel package provides a Redis mock for your tests

471.8M19](/packages/josiasmontag-laravel-redis-mock)[ied3vil/language-switcher

Laravel Language Switcher

4544.3k](/packages/ied3vil-language-switcher)[josiasmontag/laravel-localization

Localization for Laravel framework

2336.7k](/packages/josiasmontag-laravel-localization)[glebsky/laravel-lang-generator

Searches for multilingual phrases in Laravel project and automatically generates language files for you.

2423.4k](/packages/glebsky-laravel-lang-generator)

PHPackages © 2026

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