PHPackages                             keevitaja/linguist - 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. keevitaja/linguist

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

keevitaja/linguist
==================

Easy localization for the Laravel framework

3.0.0(6y ago)19110.2k↓100%15[2 issues](https://github.com/keevitaja/linguist/issues)MITPHPPHP ^7.2

Since Jul 25Pushed 6y ago7 watchersCompare

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

READMEChangelogDependencies (1)Versions (22)Used By (0)

Linguist - Multilingual urls and redirects for Laravel
======================================================

[](#linguist---multilingual-urls-and-redirects-for-laravel)

This package provides an easy multilingual urls and redirection support for the Laravel framework.

In short Laravel will generate localized urls for links and redirections.

```
route('people')
```

```
http://site.com/people
http://site.com/fr/people

```

> Linguist works perfectly well with  named Laravel routes for javascript package!

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

[](#installation)

Linguist is very easy to use. The locale slug is removed from the REQUEST\_URI leaving the developer with the cleanest multilingual environment possible.

Install using Composer:

```
composer require keevitaja/linguist
```

There are several options to make Linguist work.

### Option 1: Modify the `public/index.php`

[](#option-1-modify-the-publicindexphp)

Add following line after the vendor autoloading to your projects `public/index.php` file.

```
(new Keevitaja\Linguist\UriFixer)->fixit();
```

End result would be this:

```
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';

(new Keevitaja\Linguist\UriFixer)->fixit();
```

### Option 2: Use LocalizedKernel

[](#option-2-use-localizedkernel)

> Note: This option works only if you have not changed your applications root namespace. Default is `App`.

In your projects `bootstrap/app.php` swap the `App\Http\Kernel` with `Keevitaja\Linguist\LocalazedKernel`:

```
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    //App\Http\Kernel::class
    Keevitaja\Linguist\LocalizedKernel::class
);
```

### Option 3: modify the `App\Http\Kernel`

[](#option-3-modify-the-apphttpkernel)

> Note: This also works with custom root namespace.

```
