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

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

dashed/laravel-localization
===========================

Easy localization for Laravel

v1.0.4(10mo ago)0286[2 PRs](https://github.com/DashedCMS/dashed-laravel-localization/pulls)1MITPHPPHP ^8.3|^8.4CI passing

Since Nov 20Pushed 4mo ago1 watchersCompare

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

READMEChangelog (5)Dependencies (3)Versions (8)Used By (1)

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

[](#laravel-localization)

[![Join the chat at https://gitter.im/dashed/laravel-localization](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/dashed/laravel-localization?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Latest Stable Version](https://camo.githubusercontent.com/bcd63c898b6108d13bb01dcd41373cca102bf0fc25a44442bff2637e19a5786e/68747470733a2f2f706f7365722e707567782e6f72672f6461736865642f6c61726176656c2d6c6f63616c697a6174696f6e2f76657273696f6e2e706e67)](https://packagist.org/packages/dashed/laravel-localization) [![Total Downloads](https://camo.githubusercontent.com/2ee63fbea179a27b17893401ff20db4b451f998bfc8f530630f0245ca47b077b/68747470733a2f2f706f7365722e707567782e6f72672f6461736865642f6c61726176656c2d6c6f63616c697a6174696f6e2f642f746f74616c2e706e67)](https://packagist.org/packages/dashed/laravel-localization) [![Build Status](https://camo.githubusercontent.com/dc83fe63e562a779cb19403d57c7c02036256ad1ccd8509fc6c15f46d598b008/68747470733a2f2f7472617669732d63692e6f72672f6461736865642f6c61726176656c2d6c6f63616c697a6174696f6e2e706e67)](https://travis-ci.org/dashed/laravel-localization)[![Open Source Helpers](https://camo.githubusercontent.com/74e5aaf0016bc140f4e77ce8e7c67c436d3b64f4ec3d61bb0acaa0a7dcb68552/68747470733a2f2f7777772e636f64657472696167652e636f6d2f6461736865642f6c61726176656c2d6c6f63616c697a6174696f6e2f6261646765732f75736572732e737667)](https://www.codetriage.com/dashed/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.5.2.0-6.x (PHP version &gt;= 7 required)1.4.x6.x-10.x (PHP version &gt;= 7 required)1.8.x10.x-11.x (PHP version &gt;= 8.2 required)2.0.xInstallation
------------

[](#installation)

Install the package via composer: `composer require dashed/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="Dashed\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:

```
