PHPackages                             despark/laravel-db-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. [Framework](/categories/framework)
4. /
5. despark/laravel-db-localization

ActiveLibrary[Framework](/categories/framework)

despark/laravel-db-localization
===============================

Database localization package for laravel framework

v3.1(7y ago)113795MITPHPPHP &gt;=7.0

Since May 8Pushed 7y ago9 watchersCompare

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

READMEChangelog (10)Dependencies (7)Versions (19)Used By (0)

Laravel DB Localization for version 5.1
=======================================

[](#laravel-db-localization-for-version-51)

*Note: if you are looking for the version for Laravel 4.2 check out [v1 branch](https://github.com/despark/laravel-db-localization/tree/v1).*

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

[](#installation)

Open `composer.json` file of your project and add the following to the require array:

```
"despark/laravel-db-localization": "2.0.*"
```

Now run `composer update` to install the new requirement.

Once it's installed, you need to register the service provider in `config/app.php` in the providers array:

```
'providers' => array(
  ...
  Despark\LaravelDbLocalization\LaravelDbLocalizationServiceProvider::class,
);
```

Publish config file: `php artisan vendor:publish --provider="Despark\LaravelDbLocalization\LaravelDbLocalizationServiceProvider" --tag="config"`

Publish migrations: `php artisan vendor:publish --provider="Despark\LaravelDbLocalization\LaravelDbLocalizationServiceProvider" --tag="migrations"`

How to use it
=============

[](#how-to-use-it)

Database Example
----------------

[](#database-example)

- First you need to create your languages table

```
Schema::create('i18n', function (Blueprint $table) {
        $table->increments('id');
        $table->string('locale')->unique()->index();
        $table->string('name')->index();
        $table->timestamps();
});
```

- Example of translatable table

```
Schema::create('contacts', function (Blueprint $table) {
        $table->increments('id');

        // untranslatable columns
        $table->string('fax');
        $table->string('phone');
        $table->timestamps();
});
```

- Example of translations table

```
Schema::create('contacts_i18n', function (Blueprint $table) {

        $table->integer('contact_id')->unsigned();
        $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
        $table->integer('i18n_id')->unsigned();
        $table->foreign('i18n_id')->references('id')->on('i18n')->onDelete('cascade');

        // translatable columns
        $table->string('name', 100);
        $table->string('location', 100);

        $table->unique(['contact_id', 'i18n_id']);
        $table->primary(['contact_id', 'i18n_id']);
        $table->timestamps();
});
```

Model Example
-------------

[](#model-example)

```
use Despark\LaravelDbLocalization\i18nModelTrait;

class Contacts extends Eloquent
{
    use i18nModelTrait; // You must use i18nModelTrait

    protected $fillable = [
        'fax',
        'phone',
    ];

    protected $translator = 'Despark\LaravelDbLocalization\ContactsI18n'; // Here you need to add your translations table model name

    protected $translatorField = 'contact_id'; // your translator field name

    protected $localeField = 'i18n_id'; // here is your locale field name

    protected $translatedAttributes = ['contact_id', 'i18n_id', 'name', 'location']; // translatable fillables
}

class ContactsI18n extends Eloquent
{
    protected $table = 'contacts_i18n';
}
```

View example
------------

[](#view-example)

Create

```
{!! Form::text("fax", null) !!}
{!! Form::text("phone", null) !!}

@foreach($languages as $language)
    {!! Form::text("name[name_$language->id]", null) !!}  // Follow this convention array( fieldname_languageId );
    {!! Form::text("location[location_$language->id]", null) !!}
@endforeach
```

Retrieve

```
    // locale string
    $contacts->translate('en'); // all fields
    $contacts->translate('en')->location; // specific field

    // locale id
    $i18nId = 2;
    $contacts->translate($i18nId); // all fields
    $contacts->translate($i18nId)->location; // specific field
```

Config Example
--------------

[](#config-example)

```
config/laravel-db-localization.php
    'locale_class' => 'Despark\LaravelDbLocalization\I18n', // Eloquent model that handles your languages.
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~131 days

Total

18

Last Release

2919d ago

Major Versions

v1.2.3 → v2.0.02015-10-02

0.0.1 → v1.x-dev2016-12-14

v1.x-dev → v2.x-dev2017-01-16

v2.x-dev → v3.02017-03-21

PHP version history (3 changes)v1.1.4PHP &gt;=5.4.0

v1.x-devPHP &gt;=5.5.0

v3.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5212a50e3fabf2fa1d59e25e82386c6c4582850b41fb3984e5a584097c6888a9?d=identicon)[tbanov](/maintainers/tbanov)

---

Tags

frameworklaravellocalizationdatabasedespark

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/despark-laravel-db-localization/health.svg)

```
[![Health](https://phpackages.com/badges/despark-laravel-db-localization/health.svg)](https://phpackages.com/packages/despark-laravel-db-localization)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel-lang/publisher

Localization publisher for your Laravel application

2167.7M24](/packages/laravel-lang-publisher)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[defstudio/pest-plugin-laravel-expectations

A plugin to add laravel tailored expectations to Pest

98548.9k4](/packages/defstudio-pest-plugin-laravel-expectations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
