PHPackages                             firstpoint-ch/eloquent-translatable - 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. [Database &amp; ORM](/categories/database)
4. /
5. firstpoint-ch/eloquent-translatable

ActiveLibrary[Database &amp; ORM](/categories/database)

firstpoint-ch/eloquent-translatable
===================================

Make Laravel Eloquent Model Translatable

1.2.1(1y ago)317MITPHP

Since Sep 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/firstpoint-ch/eloquent-translatable)[ Packagist](https://packagist.org/packages/firstpoint-ch/eloquent-translatable)[ RSS](/packages/firstpoint-ch-eloquent-translatable/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

Laravel Eloquent Translatable
=============================

[](#laravel-eloquent-translatable)

Make your Eloquent Models translatable.

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

[](#installation)

You can install this package via composer by running:

```
composer require firstpoint-ch/eloquent-translatable
```

Configure models
----------------

[](#configure-models)

Models can be translated in two different ways:

1. **Database:** It stores translations as JSON in the database
2. **Dictionary:** It stores keys and retrieve translations from the global `/resources/lang/[locale].json` or any specific file in `/resources/lang/[locale]/[dictionary].php`.

First you should store any database translated field as a `json` column. This package provide a `translatable` macro so you can quickly see which fields are translatable. Fields using the dictionary mode could be set to `string`.

```
Schema::create('products', function ($table) {
    $table->id();
    $table->translatable('name'); // Outputs $table->json('name');
    $table->string('category'); // Will be used as a dictionary
    $table->decimal('price');
    $table->timestamps();
})
```

Then you should add the `Translatable` trait to the model and cast attributes using `Localized`or `Dictionary`

```
use FirstpointCh\Translatable\Casts\Dictionary;
use FirstpointCh\Translatable\Casts\Localized;
use FirstpointCh\Translatable\Traits\Translatable;

class Product extends Model
{
    use Translatable;

    protected $casts = [
        // Database
        'name' => Localized::class,
        'description' => Localized::class,

        // Dictionary:
        //get value from /resources/lang/[locale].json
        'category' => Dictionary::class,

        // or get value from /resources/lang/[locale]/categories.php
        'category' => Dictionary::class.':categories',
    ];
}
```

Basic example
-------------

[](#basic-example)

Here's a quick look of what this package can do, check our [extended documentation](https://docs.firstpoint.ch/eloquent-translatable) for all the details.

```
app()->setLocale('en');

// Set translation in the current locale
$product = Product::create(['name' => 'Product name']);

// Get translation in the current locale
echo $product->name; // Product name

// Get array in the current locale
dd($product->toArray()); // ['name' => 'Product name']

// Update the current locale
$product->update(['name' => 'New name']);

// Update a specific locale
$product->update(['name->fr' => 'Nom du produit']);

// Force a locale
echo $product->in('fr')->name; // Nom du produit

// Get raw value
dd($product->raw('name')); // ['en' => 'Product name', 'fr' => 'Nom du produit']
dd($product->in('*')->toArray()); // ['name' => ['en' => 'Product name', 'fr' => 'Nom du produit']]
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% of commits — single point of failure

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 ~305 days

Total

5

Last Release

533d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9134609?v=4)[Frédéric Marmillod](/maintainers/fredmarmillod)[@fredmarmillod](https://github.com/fredmarmillod)

---

Top Contributors

[![fredmarmillod](https://avatars.githubusercontent.com/u/9134609?v=4)](https://github.com/fredmarmillod "fredmarmillod (22 commits)")[![jbunning](https://avatars.githubusercontent.com/u/28430868?v=4)](https://github.com/jbunning "jbunning (1 commits)")

### Embed Badge

![Health badge](/badges/firstpoint-ch-eloquent-translatable/health.svg)

```
[![Health](https://phpackages.com/badges/firstpoint-ch-eloquent-translatable/health.svg)](https://phpackages.com/packages/firstpoint-ch-eloquent-translatable)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)

PHPackages © 2026

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