PHPackages                             longman/laravel-multilang - 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. longman/laravel-multilang

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

longman/laravel-multilang
=========================

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5.0.1(1y ago)5514.4k15[4 issues](https://github.com/akalongman/laravel-multilang/issues)[3 PRs](https://github.com/akalongman/laravel-multilang/pulls)1MITPHPPHP ^8.1.0

Since Apr 18Pushed 1y ago6 watchersCompare

[ Source](https://github.com/akalongman/laravel-multilang)[ Packagist](https://packagist.org/packages/longman/laravel-multilang)[ Docs](https://github.com/akalongman/laravel-multilang)[ RSS](/packages/longman-laravel-multilang/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (56)Used By (1)

Laravel 5.x MultiLanguage
=========================

[](#laravel-5x-multilanguage)

[![Build Status](https://camo.githubusercontent.com/f2bcb01350483fbde3db52c66cf52321083bd6df352bfa971a73ea145104be89/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f616b616c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/akalongman/laravel-multilang)[![Code Coverage](https://camo.githubusercontent.com/b17f201dbbf50bcee1b4c0c7f380bd4b2adf09655769c9132d9349d680ea4fc9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f616b616c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/akalongman/laravel-multilang/?branch=master)[![Code Quality](https://camo.githubusercontent.com/467db6fd7c28c6ccfe762294c9f4660cba5595e793ea7fc389a3b72e23d3b6dd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f616b616c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/akalongman/laravel-multilang/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/b91df1289029edf3b68a00793623eade50a7937bda1079dac229e0b12794ae32/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f616b616c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672e7376673f7374796c653d666c61742d737175617265)](https://github.com/akalongman/laravel-multilang/releases)[![Total Downloads](https://camo.githubusercontent.com/20341df3a4624ed354b05b97557688f664ee04fddb90c3a18a37d3eb95350d83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672e737667)](https://packagist.org/packages/longman/laravel-multilang)[![Downloads Month](https://camo.githubusercontent.com/4b5fcfcd0f7573e666c8c12ef6f8e8f1aadb124fb9232fa409e0b688f0b89be2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f4c6f6e676d616e2f6c61726176656c2d6d756c74696c616e672e737667)](https://packagist.org/packages/longman/laravel-multilang)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

*This version of MultiLang package requires minimum PHP 7.0. For older PHP versions use MultiLang [1.x](https://github.com/akalongman/laravel-multilang/releases/tag/1.3.3)*

This is a very useful package to integrate multi language (multi locale) functionality in Laravel 5.x. It includes a ServiceProvider to register the multilang and Middleware for automatic modification routes like `http://site.com/en/your-routes`.

This package uses database for storing translations (it caches data on production environment for improving performance) Also package automatically adds in database missing keys (on the local environment only).

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
    - [Translating](#translating)
    - [Blade Templates](#blade-templates)
    - [URL Generation](#url-generation)
    - [Text Scopes](#text-scopes)
    - [Import/Export Texts](#importexport-texts)
- [TODO](#todo)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
- [Credits](#credits)

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

[](#installation)

Install this package through [Composer](https://getcomposer.org/).

Edit your project's `composer.json` file to require `longman/laravel-multilang`

Create *composer.json* file:

```
{
    "name": "yourproject/yourproject",
    "type": "project",
    "require": {
        "longman/laravel-multilang": "~2.0"
    }
}
```

And run composer update

**Or** run a command in your command line:

```
composer require longman/laravel-multilang

```

In Laravel the service provider and facade will automatically get registered.

Copy the package config to your local config with the publish command:

```
php artisan vendor:publish --provider="Longman\LaravelMultiLang\MultiLangServiceProvider"

```

After run multilang migration command

```
php artisan multilang:migration

```

Its creates multilang migration file in your database/migrations folder. After you can run

```
php artisan migrate

```

Also if you want automatically change locale depending on url (like `http://site.com/en/your-routes`) you must add middleware in app/Http/Kernel.php

I suggest add multilang after CheckForMaintenanceMode middleware

```
protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
    \Longman\LaravelMultiLang\Middleware\MultiLang::class,
];
```

In your RoutesServiceProvider modify that:

```
MultiLang::routeGroup(function($router) {
    require app_path('Http/routes.php');
});
```

or directly in app/Http/routes.php file add multilang group:

```
MultiLang::routeGroup(function($router) {
    // your routes and route groups here
});
```

Or if you want only translate strings without automatic resolving locale and redirect, you can manually set locale in your application like:

```
App::setLocale('en');
```

Usage
-----

[](#usage)

### Translating

[](#translating)

Everywhere in application you can use `t()` helper function like:

```
$string = t('Your translatable string');
```

You can use markers for dynamic texts and pass any data like

```
$string = t('The :attribute must be a date after :date.', ['attribute' => 'Start Date', 'date' => '7 April 1986']);
```

which will be return `The Start Date must be a date after 7 April 1986.`

### Blade Templates

[](#blade-templates)

In blade templates you can use just `@t()` notation like

```
@t('Your translatable string')
```

which is equivalent to `{{ t('Your translatable string') }}`

### URL Generation

[](#url-generation)

Also you can use `lang_url()` helper function for appending current lang marker in urls automatically.

```
$url = lang_url('users'); // which returns /en/users depending on your language (locale)
```

You can force locale and get localized url for current url for example.

```
$url = lang_url('users', [], null, 'ka'); // which returns /ka/users ignoring current locale
```

or

```
$url = lang_url('en/users', [], null, 'ka'); // also returns /ka/users
```

Also you use named routes via `lang_route()` function

```
$url = lang_route('users'); // which returns en.users depending on your language (locale)
```

Also `Request::locale()` always will return current locale.

*Note*: Texts will be selected after firing Laravel's `LocaleUpdated` event. Therefore you should use MultiLang middleware, or manually set locale in the application.

### Text Scopes

[](#text-scopes)

If you want group translations by some scope, in package available defining of scopes. For example to define scope `admin` in application, you should call:

```
app('multilang')->setScope('admin');
```

before setting the locale.

*Note*: Default scope is `global`

### Import/Export Texts

[](#importexport-texts)

For versioning texts with source code (git/svn) and easy management, there is possible import texts from yml file and also export in the file.

yml file format is:

```
-
  key: 'authorization'
  texts:
    en: 'Authorization'
    ge: 'ავტორიზაცია'
-
  key: 'registration'
  texts:
    en: 'Registration'
    ge: 'რეგისტრაცია'
```

Run commands for possible options and more information:

```
php artisan help multilang:import

php artisan help multilang:export

```

TODO
----

[](#todo)

write more tests

Troubleshooting
---------------

[](#troubleshooting)

If you like living on the edge, please report any bugs you find on the [laravel-multilang issues](https://github.com/akalongman/laravel-multilang/issues) page.

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

[](#contributing)

Pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for information.

License
-------

[](#license)

Please see the [LICENSE](LICENSE.md) included in this repository for a full copy of the MIT license, which this project is licensed under.

Credits
-------

[](#credits)

- [Avtandil Kikabidze aka LONGMAN](https://github.com/akalongman)

Full credit list in [CREDITS](CREDITS)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.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 ~60 days

Recently: every ~322 days

Total

51

Last Release

646d ago

Major Versions

0.2.0 → 1.0.02016-08-18

1.3.3 → 2.0.02019-12-17

1.1.10 → 3.0.02020-03-27

3.0.6 → 4.0.02022-05-02

4.0.0 → 5.0.02023-06-14

PHP version history (5 changes)0.1.0PHP &gt;=5.5.9

2.0.0PHP ^7.2

2.0.1PHP ^7.3

3.0.4PHP ^7.4|^8.0

4.0.0PHP ^8.1.0

### Community

Maintainers

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

---

Top Contributors

[![akalongman](https://avatars.githubusercontent.com/u/423050?v=4)](https://github.com/akalongman "akalongman (168 commits)")[![papavadze](https://avatars.githubusercontent.com/u/6769758?v=4)](https://github.com/papavadze "papavadze (5 commits)")[![marttosc](https://avatars.githubusercontent.com/u/4406643?v=4)](https://github.com/marttosc "marttosc (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![SkylineGTRS](https://avatars.githubusercontent.com/u/50054550?v=4)](https://github.com/SkylineGTRS "SkylineGTRS (1 commits)")[![thecotne](https://avatars.githubusercontent.com/u/1606993?v=4)](https://github.com/thecotne "thecotne (1 commits)")[![unnawut](https://avatars.githubusercontent.com/u/921194?v=4)](https://github.com/unnawut "unnawut (1 commits)")

---

Tags

laravellaravel-packagelocalizationmultilangphplaravellocalizationlanguagepackagetranslationlocalemultilang

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/longman-laravel-multilang/health.svg)

```
[![Health](https://phpackages.com/badges/longman-laravel-multilang/health.svg)](https://phpackages.com/packages/longman-laravel-multilang)
```

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

Package for convenient work with Laravel's localization features

3527.1k4](/packages/awes-io-localization-helper)

PHPackages © 2026

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