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

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

jesprna/jaysfi-language
=======================

Language switcher package for Laravel

v1.0.0(4mo ago)0431↓50%MITPHPPHP ^7.2|^8.0

Since Jan 10Pushed 4mo agoCompare

[ Source](https://github.com/jesprna/jaysfi-language)[ Packagist](https://packagist.org/packages/jesprna/jaysfi-language)[ RSS](/packages/jesprna-jaysfi-language/feed)WikiDiscussions master Synced 1mo ago

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

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

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

[![Downloads](https://camo.githubusercontent.com/a225774f4d69dccba1279c24e6e0c6f8c1f60f933fe3f10576b317b4e274958c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a657370726e612f6a61797366692d6c616e6775616765)](https://camo.githubusercontent.com/a225774f4d69dccba1279c24e6e0c6f8c1f60f933fe3f10576b317b4e274958c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a657370726e612f6a61797366692d6c616e6775616765)[![Tests](https://github.com/jesprna/jaysfi-language/workflows/Tests/badge.svg)](https://github.com/jesprna/jaysfi-language/workflows/Tests/badge.svg)[![StyleCI](https://camo.githubusercontent.com/1d0850fd3a99b579d562e087be35c7fad63cdcaf642e7e90c49d76070b0d8891/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3130323239303234392f736869656c643f7374796c653d666c6174266272616e63683d6d6173746572)](https://styleci.io/repos/102290249)[![Quality](https://camo.githubusercontent.com/6e476e03cff473494c71e925a8be4eac9b4c6cedd58a0a806f2e7266977fb120/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6a657370726e612f6a61797366692d6c616e67756167653f6c6162656c3d7175616c697479)](https://scrutinizer-ci.com/g/jesprna/jaysfi-language)[![License](https://camo.githubusercontent.com/122a363f6c9d41c37322b3491a2b04b714945fb588d8238cc1a5cc3f68243574/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a657370726e612f6a61797366692d6c616e6775616765)](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.

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

[](#version-compatibility)

LaravelPHPPackage5.87.2 - 7.4^2.06.x7.2 - 8.0^2.07.x7.2 - 8.0^2.08.x7.3 - 8.1^2.09.x8.0 - 8.2^2.010.x8.1 - 8.3^2.011.x8.2 - 8.4^2.012.x8.2 - 8.5^2.0**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 jesprna/jaysfi-language

```

### 2. Register (Optional - Laravel 5.5+ Auto-Discovery)

[](#2-register-optional---laravel-55-auto-discovery)

> **Note**: Laravel 5.5+ automatically discovers the package. Manual registration is only needed for older versions.

For Laravel &lt; 5.5, register the service provider in `config/app.php`:

```
Jesprna\Language\Provider::class,
```

Add alias if you want to use the facade:

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

### 3. Publish

[](#3-publish)

Publish config, migration and blade files.

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

**Optional:** Publish flag images for customization (only if you want to replace flag images):

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

This will copy flag images to `public/vendor/language/flags/` where you can replace them with your custom flags. The package will automatically use your custom flags if they exist, otherwise it will use the default package flags.

### 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.

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Pull requests are more than welcome. You must follow the PSR coding standards.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Jays](https://github.com/jesprna)
- [Cüneyt Şentürk](https://github.com/cuneytsenturk)
- [Denis Duliçi](https://github.com/denisdulici)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance78

Regular maintenance activity

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 67.7% 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

Unknown

Total

1

Last Release

120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/999042c0244396cbd9fbee3654cbc6ab436604538a3b3daac92505b4bfbec06f?d=identicon)[jesprna](/maintainers/jesprna)

---

Top Contributors

[![denisdulici](https://avatars.githubusercontent.com/u/5254835?v=4)](https://github.com/denisdulici "denisdulici (44 commits)")[![cuneytsenturk](https://avatars.githubusercontent.com/u/10936547?v=4)](https://github.com/cuneytsenturk "cuneytsenturk (7 commits)")[![jesprna](https://avatars.githubusercontent.com/u/48647209?v=4)](https://github.com/jesprna "jesprna (3 commits)")[![muhammadn](https://avatars.githubusercontent.com/u/3349747?v=4)](https://github.com/muhammadn "muhammadn (2 commits)")[![dasturchiuz](https://avatars.githubusercontent.com/u/5771731?v=4)](https://github.com/dasturchiuz "dasturchiuz (2 commits)")[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (2 commits)")[![drsdre](https://avatars.githubusercontent.com/u/809827?v=4)](https://github.com/drsdre "drsdre (2 commits)")[![vibrantBits](https://avatars.githubusercontent.com/u/3849951?v=4)](https://github.com/vibrantBits "vibrantBits (1 commits)")[![EnesSacid-Buker](https://avatars.githubusercontent.com/u/73346401?v=4)](https://github.com/EnesSacid-Buker "EnesSacid-Buker (1 commits)")[![BlackIkeEagle](https://avatars.githubusercontent.com/u/293691?v=4)](https://github.com/BlackIkeEagle "BlackIkeEagle (1 commits)")

---

Tags

laravellanguageswitcher

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[akaunting/laravel-language

Language switcher package for Laravel

223285.2k1](/packages/akaunting-laravel-language)[josiasmontag/laravel-redis-mock

This Laravel package provides a Redis mock for your tests

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

Laravel Language Switcher

4543.6k](/packages/ied3vil-language-switcher)[pmochine/laravel-tongue

🎉 Finally a subdomain localization that works how you want it to work. 🌐

4158.4k](/packages/pmochine-laravel-tongue)[josiasmontag/laravel-localization

Localization for Laravel framework

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

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

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

PHPackages © 2026

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