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

ActiveLibrary

alihan/laravel-localization
===========================

Easy localization for Laravel

00PHP

Since Apr 26Pushed 3y agoCompare

[ Source](https://github.com/alihan0/laravel-localization)[ Packagist](https://packagist.org/packages/alihan/laravel-localization)[ RSS](/packages/alihan-laravel-localization/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-localization)

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

[![Latest Stable Version](https://camo.githubusercontent.com/607c5caf11da2679850f2ac88101ad7a034eb01447078f7abd24a8434e826d4a/68747470733a2f2f706f7365722e707567782e6f72672f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2f76657273696f6e2e706e67)](https://packagist.org/packages/mcamara/laravel-localization) [![Total Downloads](https://camo.githubusercontent.com/4c163356b80cbd79e46fc79dbfe593609579ac4df6e56b11bfa189bd2a5fc528/68747470733a2f2f706f7365722e707567782e6f72672f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2f642f746f74616c2e706e67)](https://packagist.org/packages/mcamara/laravel-localization) [![Build Status](https://camo.githubusercontent.com/a6757316aa8695da8711dbac4dcfc542247b951dc1919089558f858a49e69c86/68747470733a2f2f7472617669732d63692e6f72672f6d63616d6172612f6c61726176656c2d6c6f63616c697a6174696f6e2e706e67)](https://travis-ci.org/mcamara/laravel-localization)[![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.5.2.0-6.x (PHP version &gt;= 7 required)1.4.x6.x-10.x (PHP version &gt;= 7 required)1.8.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:

```
