PHPackages                             koenhoeijmakers/laravel-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. [Localization &amp; i18n](/categories/localization)
4. /
5. koenhoeijmakers/laravel-translatable

Abandoned → [astrotomic/laravel-translatable](/?search=astrotomic%2Flaravel-translatable)ArchivedLibrary[Localization &amp; i18n](/categories/localization)

koenhoeijmakers/laravel-translatable
====================================

Laravel Translations

v0.6.0(6y ago)117361[1 issues](https://github.com/koenhoeijmakers/laravel-translatable/issues)MITPHPPHP &gt;=7.2.5

Since May 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/koenhoeijmakers/laravel-translatable)[ Packagist](https://packagist.org/packages/koenhoeijmakers/laravel-translatable)[ RSS](/packages/koenhoeijmakers-laravel-translatable/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (13)Used By (0)

Laravel Translatable
====================

[](#laravel-translatable)

[![Packagist](https://camo.githubusercontent.com/7814f6dcf68a90fc8df41c2c95d948cc25f65e39c96ebd514e86c8b36f866820/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652e7376673f636f6c6f72423d627269676874677265656e)](https://packagist.org/packages/koenhoeijmakers/laravel-translatable)[![Build Status](https://camo.githubusercontent.com/7cc3c280ec43ebd8660fc01c97230d445ec2751577bcd383886f3d9656653709/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/koenhoeijmakers/laravel-translatable/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/d0074a49eef413b7457999b1a2e4615c182ccd0ae142da13e5214c8746f85b3f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/koenhoeijmakers/laravel-translatable/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ebfe0518e144d85c764d4407199dc94e06e44e8269afbc872e45117bab8e72fe/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/koenhoeijmakers/laravel-translatable/?branch=master)[![license](https://camo.githubusercontent.com/a61a4547f24e1efe2ddd4e5172cea484fac9d6cad8807ad3753c9df5870e2d4c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652e7376673f636f6c6f72423d627269676874677265656e)](https://github.com/koenhoeijmakers/laravel-translatable)[![Packagist](https://camo.githubusercontent.com/5bddb23324602856df6e95751036e3fa0be8c1af72f423158ca361a0b98c3034/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6f656e686f65696a6d616b6572732f6c61726176656c2d7472616e736c617461626c652e7376673f636f6c6f72423d627269676874677265656e)](https://packagist.org/packages/koenhoeijmakers/laravel-translatable)

A fresh new way to handle Model translations, the translations are joined into the Model instead of making you query a relation or get every single attribute's translation one by one.

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

[](#installation)

Require the package.

```
composer require koenhoeijmakers/laravel-translatable
```

... and optionally publish the config.

```
php artisan vendor:publish --provider="KoenHoeijmakers\LaravelTranslatable\TranslatableServiceProvider"
```

Usage
-----

[](#usage)

### Setting up a translatable Model.

[](#setting-up-a-translatable-model)

Start off by creating a migration and a Model, we'll go with the `Animal` Model and the corresponding `AnimalTranslation` Model.

#### Migrations

[](#migrations)

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

Always have a `locale` and a `foreign_key` to the original Model, in our case `animal_id`.

```
Schema::create('animal_translations', function (Blueprint $table) {
    $table->increments('id');
    $table->unsignedInteger('animal_id');
    $table->string('locale');
    $table->string('name');
    $table->timestamps();

    $table->unique(['locale', 'animal_id']);
    $table->foreign('animal_id')->references('id')->on('animals');
});
```

#### Models

[](#models)

Register the trait on the Model, and add the columns that should be translated to the `$translatable` property, **But also make them fillable**, this is because the saving is handled through events, this way we don't have to change the `save` method and makes the package more interoperable.

> So make sure the `$translatable` columns are also `$fillable` on both Models.

```
use Illuminate\Database\Eloquent\Model;
use KoenHoeijmakers\LaravelTranslatable\HasTranslations;

class Animal extends Model
{
    use HasTranslations;

    protected $translatable = ['name'];

    protected $fillable = ['name'];
}
```

```
use Illuminate\Database\Eloquent\Model;

class AnimalTranslation extends Model
{
    protected $fillable = ['name'];
}
```

This is pretty much all there is to it, but you can read more about the package down here.

About
-----

[](#about)

What makes this package so special is the way it handles the translations, how it retrieves them, how it stores them, and how it queries them.

### Querying

[](#querying)

Due to how the package handles the translations, querying is a piece of cake, while for other packages you would have a `->whereTranslation('nl', 'column', '=', 'foo')` method.

But in this package you can just do `->where('column', '=', 'foo')` and it'll know what to query, just query how you used to!

### Retrieving

[](#retrieving)

When you retrieve a Model from the database, the package will join the translation table with the translation of the current locale `config/app.php`.

This makes it so that any translated column acts like it is "native" to the Model, due to this we don't have to override a lot of methods on the Model which is a big plus.

Need the Model in a different language? Call `$model->translate('nl')` and you are done. Now you would like to save the `nl` translation? just call `->update()`. The Model knows in which locale it is loaded and it will handle it accordingly.

```
$animal = Animal::query()->find(1);

$animal->translate('nl')->update(['name' => 'Aap']);
```

### Storing

[](#storing)

You will be storing your translations as if they're attributes on the Model, so this will work like a charm:

```
Animal::query()->create(['name' => 'Monkey']);
```

But i hear you, you would like to store multiple translations in one request! In that so you can use the `->storeTranslation()` or the `->storeTranslations()` method.

```
$animal = Animal::query()->create(['name' => 'Monkey']);

$animal->storeTranslation('nl', [
    'name' => 'Aap',
]);

$animal->storeTranslations([
    'nl' => [
        'name' => 'Aap',
    ],
    'de' => [
        'name' => 'Affe',
    ],
]);
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.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 ~61 days

Recently: every ~108 days

Total

12

Last Release

2229d ago

PHP version history (2 changes)v0.1.0PHP &gt;=7.2

v0.6.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2232776?v=4)[Koen Hoeijmakers](/maintainers/koenhoeijmakers)[@koenhoeijmakers](https://github.com/koenhoeijmakers)

---

Top Contributors

[![koenhoeijmakers](https://avatars.githubusercontent.com/u/2232776?v=4)](https://github.com/koenhoeijmakers "koenhoeijmakers (85 commits)")[![ricardovanlaarhoven](https://avatars.githubusercontent.com/u/1246691?v=4)](https://github.com/ricardovanlaarhoven "ricardovanlaarhoven (1 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")

---

Tags

laravellaravel-localizationlaravel-translationstranslatabletranslations

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mcamara/laravel-localization

Easy localization for Laravel

3.5k9.1M112](/packages/mcamara-laravel-localization)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.3k](/packages/typicms-base)[vemcogroup/laravel-translation

Translation package for Laravel to scan for localisations and up/download to poeditor

135304.0k2](/packages/vemcogroup-laravel-translation)

PHPackages © 2026

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