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 yesterday

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

31

—

LowBetter than 68% of packages

Maintenance42

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

478d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d84211a19e9971ef638bfe3c8c6ef2cbf5ddf82a81567605ca9b2953cbb061aa?d=identicon)[fredmarmillod](/maintainers/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

[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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