PHPackages                             corecave/laratrans - 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. corecave/laratrans

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

corecave/laratrans
==================

Laravel helper package for building database mutli-lang websites.

v1.0.1(5y ago)16MITPHP

Since Jul 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/corecave/laratrans)[ Packagist](https://packagist.org/packages/corecave/laratrans)[ RSS](/packages/corecave-laratrans/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (3)Used By (0)

Laratrans for Laravel - Laravel &gt;= 7.0
=========================================

[](#laratrans-for-laravel---laravel--70)

[![GitHub issues](https://camo.githubusercontent.com/8ab3aefc6b03ae30047fe2dcc3987b01c4784de1582c84845a6244e5d24c07b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f636f7265636176652f6c6172617472616e73)](https://github.com/corecave/laratrans/issues)[![GitHub forks](https://camo.githubusercontent.com/7d3e8edbe2ac16bd3fd3a674d820e26a74c24b5dda18e2ca9d57c6b2d799f70e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f636f7265636176652f6c6172617472616e73)](https://github.com/corecave/laratrans/network)[![GitHub stars](https://camo.githubusercontent.com/8ff91a95a792207b17d157a2a1653f12e372ce29c4be5da8b7e42c43d75c251d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f636f7265636176652f6c6172617472616e73)](https://github.com/corecave/laratrans/stargazers)[![GitHub license](https://camo.githubusercontent.com/418ee3288c544972df1b1fd6d3275fb9ccbca06f1c8cf2d572ca213affd0d974/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636f7265636176652f6c6172617472616e73)](https://github.com/corecave/laratrans/blob/master/LICENSE.txt)

Laravel translation package for building database localized mutli-lang websites..

Contents
--------

[](#contents)

- [Laratrans for Laravel - Laravel &gt;= 7.0](#laratrans-for-laravel---laravel--70)
    - [Contents](#contents)
    - [Installation](#installation)
    - [Usage](#usage)
    - [Change Application Locale.](#change-application-locale)
    - [Consider a donation](#consider-a-donation)
    - [Credits](#credits)
    - [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require corecave/laratrans
```

Laravel auto-discovery with discover the service provicer
OR
Add the service provider manually:

```
// config/app.php
'providers' => [
    // ...
    CoreCave\Laratrans\LaratransServiceProvider::class,
],
```

Append `CoreCave\Laratrans\Middleware\Locale` to the `$routeMiddleware` array in `app\Http\Kernel.php` file.

```
// app\Http\Kernel.php
  protected $routeMiddleware = [
        // ...

        'laratrans' => \CoreCave\Laratrans\Middleware\Locale::class,
    ];
```

Put your database credentials to your `.env` file

Then you should migrate the database

```
php artisan migrate
```

Usage
-----

[](#usage)

After you have installed laratrans package you need to add the `MasterTranslatable` and `DetailsTranslatable` traits to your models that you want to make localizable. Additionaly,
NOTE:- Please note that slave model must be proceeded with underscore `_` and its related table must be proceeded by double underscore `__` (e.g. `Person` =&gt; `_Person` , `people` =&gt; `__people`)
Then, define the fields required by the package for localization to work properly on your migration:

```
//app\Person.php
