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

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

mcamara/laravel-localization
============================

Easy localization for Laravel

v2.4.0(2mo ago)3.5k9.1M—7.1%520[38 issues](https://github.com/mcamara/laravel-localization/issues)[13 PRs](https://github.com/mcamara/laravel-localization/pulls)20MITPHPPHP ^8.2CI passing

Since Jan 19Pushed 2mo ago89 watchersCompare

[ Source](https://github.com/mcamara/laravel-localization)[ Packagist](https://packagist.org/packages/mcamara/laravel-localization)[ Docs](https://github.com/mcamara/laravel-localization)[ GitHub Sponsors](https://github.com/iwasherefirst2)[ GitHub Sponsors](https://github.com/mcamara)[ RSS](/packages/mcamara-laravel-localization/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (106)Used By (20)

Laravel Localization
====================

[](#laravel-localization)

[![Latest Version on Packagist](https://camo.githubusercontent.com/eae7deb3607b7969f538efa62939de081b961abbd49722c667532dbdc01efb2e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mcamara/laravel-localization)[![Total Downloads](https://camo.githubusercontent.com/5079ccb1bd7aa55e2a258e8ca193e8ac7085e65a8d5748858378458cfc4a36b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mcamara/laravel-localization)[![GitHub Actions](https://github.com/mcamara/laravel-localization/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mcamara/laravel-localization/actions/workflows/run-tests.yml/badge.svg)[![Open Source Helpers](https://camo.githubusercontent.com/a8b9b2fc63486bbdee128e9531ef12793a032bd5dbff856400712e69e49de96b/68747470733a2f2f7777772e636f64657472696167652e636f6d2f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2f6261646765732f75736572732e737667)](https://www.codetriage.com/mcamara/laravel-localization)[![Reviewed by Hound](https://camo.githubusercontent.com/5d8f6d94715fbd69d4f1c74b9825421774847089f891b382cd4acb4bb63a0a25/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52657669657765645f62792d486f756e642d3845363442302e737667)](https://houndci.com)

Easy i18n localization for Laravel, an useful tool to combine with Laravel localization classes.

The package offers the following:

- Detect language from browser
- Smart redirects (Save locale in session/cookie)
- Smart routing (Define your routes only once, no matter how many languages you use)
- Translatable Routes
- Supports caching &amp; testing
- Option to hide default locale in url
- Many snippets and helpers (like language selector)

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

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Redirect Middleware](#redirect-middleware)
- [Helpers](#helpers)
- [Translated Routes](#translated-routes)
- [Caching routes](#caching-routes)
- [Testing](#testing)
- [Common Issues](#common-issues)
    - [POST is not working](#post-is-not-working)
    - [MethodNotAllowedHttpException](#methodnotallowedhttpexception)
    - [Validation message is always in default locale](#validation-message-is-only-in-default-locale)
- [Collaborators](#collaborators)
- [Changelog](#changelog)
- [License](#license)

Laravel compatibility
---------------------

[](#laravel-compatibility)

Laravellaravel-localization4.0.x0.13.x4.1.x0.13.x4.2.x0.15.x5.0.x/5.1.x1.0.x5.2.x-5.4.x (PHP 7 not required)1.2.x5.2.0-6.x (PHP version &gt;= 7 required)1.4.x6.x-10.x (PHP version &gt;= 7 required)1.8.x10.x-13.x (PHP version &gt;= 8.2 required)2.0.xInstallation
------------

[](#installation)

Install the package via composer: `composer require mcamara/laravel-localization`

For Laravel 5.4 and below it necessary to [register the service provider](/ADDITIONS.md#for-laravel-5.4-and-below).

### Config Files

[](#config-files)

In order to edit the default configuration you may execute:

```
php artisan vendor:publish --provider="Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider"

```

After that, `config/laravellocalization.php` will be created.

The configuration options are:

- **supportedLocales** Languages of your app (Default: English &amp; Spanish).
- **useAcceptLanguageHeader** If true, then automatically detect language from browser.
- **hideDefaultLocaleInURL** If true, then do not show default locale in url.
- **localesOrder** Sort languages in custom order.
- **localesMapping** Rename url locales.
- **utf8suffix** Allow changing utf8suffix for CentOS etc.
- **urlsIgnored** Ignore specific urls.

### Register Middleware

[](#register-middleware)

You may register the package middleware in the `app/Http/Kernel.php` file:

```
