PHPackages                             typicms/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. typicms/translatable

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

typicms/translatable
====================

A trait to make an Eloquent model hold translations

2.0.1(3mo ago)12.5k↑1472.7%[1 PRs](https://github.com/typicms/translatable/pulls)4MITPHPPHP ^8.0CI passing

Since Nov 2Pushed 2mo agoCompare

[ Source](https://github.com/typicms/translatable)[ Packagist](https://packagist.org/packages/typicms/translatable)[ Docs](https://github.com/typicms/translatable)[ GitHub Sponsors](https://github.com/typicms)[ RSS](/packages/typicms-translatable/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (10)Versions (6)Used By (4)

A trait to make Eloquent models translatable
============================================

[](#a-trait-to-make-eloquent-models-translatable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5a8966b6638970191548db50cd96ab9d71217f592c218573b8f94f633c3b6300/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74797069636d732f7472616e736c617461626c652e737667)](https://packagist.org/packages/typicms/translatable)[![MIT Licensed](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![run-tests](https://github.com/typicms/translatable/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/typicms/translatable/actions/workflows/tests.yml)[![PHPStan](https://github.com/typicms/translatable/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/typicms/translatable/actions/workflows/phpstan.yml)[![Rector](https://github.com/typicms/translatable/actions/workflows/rector.yml/badge.svg?branch=main)](https://github.com/typicms/translatable/actions/workflows/rector.yml)

This project is based on spatie/laravel-translatable, it resolves inconsistencies that have arisen over time in the initial project.

This package contains a trait `HasTranslations` to make Eloquent models translatable. Translations are stored as json. There is no extra table needed to hold them.

```
use Illuminate\Database\Eloquent\Model;
use TypiCMS\Translatable\HasTranslations;

class NewsItem extends Model
{
    use HasTranslations;

    // ...
}
```

After the trait is applied on the model, you can do these things:

```
$newsItem = new NewsItem;
$newsItem
   ->setTranslation('name', 'en', 'Name in English')
   ->setTranslation('name', 'nl', 'Naam in het Nederlands')
   ->save();

$newsItem->name; // Returns 'Name in English' given that the current app locale is 'en'
$newsItem->getTranslation('name', 'nl'); // returns 'Naam in het Nederlands'

app()->setLocale('nl');

$newsItem->name; // Returns 'Naam in het Nederlands'

// If you want to query records based on locales, you can use the `whereLocale` and `whereLocales` methods.

NewsItem::whereLocale('name', 'en')->get(); // Returns all news items with a name in English

NewsItem::whereLocales('name', ['en', 'nl'])->get(); // Returns all news items with a name in English or Dutch
```

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you've found a bug regarding security, please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [Samuel De Backer](https://github.com/sdebacker)
- [All Contributors](https://github.com/spatie/laravel-translatable/graphs/contributors)

We got the idea to store translations as JSON in a column from [Mohamed Said](https://github.com/themsaid). Parts of the readme of [his multilingual package](https://github.com/themsaid/laravel-multilingual) were used in this readme.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance84

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~65 days

Total

3

Last Release

102d ago

Major Versions

1.0.0 → 2.0.02026-03-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/b93740e4c6b40a6219441696db5db9c4b635dad91339c1893dfe0813434e8d94?d=identicon)[Samuel De Backer](/maintainers/Samuel%20De%20Backer)

---

Top Contributors

[![sdebacker](https://avatars.githubusercontent.com/u/134503?v=4)](https://github.com/sdebacker "sdebacker (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laraveltranslatemodeleloquentmultilingualtranslatablei10nTypiCMS

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/typicms-translatable/health.svg)

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

###  Alternatives

[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k25.2M497](/packages/spatie-laravel-translatable)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.0M87](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[spatie/laravel-sluggable

Generate slugs when saving Eloquent models

1.5k12.4M293](/packages/spatie-laravel-sluggable)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M152](/packages/spatie-laravel-health)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4833.0M9](/packages/dyrynda-laravel-model-uuid)

PHPackages © 2026

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