PHPackages                             signifly/laravel-translator - 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. signifly/laravel-translator

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

signifly/laravel-translator
===========================

Database based translations for your Eloquent models.

v2.0.0(2y ago)63.1kMITPHPPHP ^7.2.5|^8.0

Since Mar 8Pushed 2y ago2 watchersCompare

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

READMEChangelog (10)Dependencies (5)Versions (22)Used By (0)

Database based translations for your Eloquent models
====================================================

[](#database-based-translations-for-your-eloquent-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3e8dca3369377f9337b089c38edaf795ca6dedb403ee587000b8cba7e591e121/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369676e69666c792f6c61726176656c2d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signifly/laravel-translator)[![Build Status](https://camo.githubusercontent.com/54b3dcf669f99cdc5cebac6172967c742be2ea3aee5f84d04de89cbac42dfe7d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7369676e69666c792f6c61726176656c2d7472616e736c61746f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/signifly/laravel-translator)[![StyleCI](https://camo.githubusercontent.com/9f44f547eb75443397ef28f1d15dd4e2d1da2b39c26fedd333f62b9e32ae13ea/68747470733a2f2f7374796c6563692e696f2f7265706f732f3137343332333238352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/174323285)[![Quality Score](https://camo.githubusercontent.com/dbc66a0e774dcbbad060ddd20fb1d2efde06b0c46059aee3494d67137988a3e3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7369676e69666c792f6c61726176656c2d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/signifly/laravel-translator)[![Total Downloads](https://camo.githubusercontent.com/a75af4163ce49c0ccbefb2cfb229d5988e28d30fbdf3cce25f3c0f24af90fe18/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369676e69666c792f6c61726176656c2d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signifly/laravel-translator)

The `signifly/laravel-translator` package allows you to easily add database based translations to your Eloquent models.

Below is a small example of how to use it:

```
// Add the trait to your translatable models
use Signifly\Translator\Concerns\Translatable;

class Post extends Model
{
    use Translatable;

    /** @var array */
    protected $translatable = [
        'title', 'description',
    ];
}
```

In order to store translations, you can do the following:

```
$post = Post::find(1);
$post->translate('en', [
    'title' => 'Some title',
    'description' => 'description',
]);
// returns a Illuminate\Support\Collection of translations
```

You can also translate a single attribute:

```
$post->translateAttribute('en', 'title', 'Some title');
// returns Signifly\Translator\Contracts\Translation
```

If you want to update the model's attributes as well, it can be accomplished using:

```
Post::createAndTranslate('en', [
    'title' => 'Some title',
    'description' => 'description',
]);

// or when updating
$post->updateAndTranslate('en', [
    'title' => 'New title',
    'description' => 'New description',
]);
```

The `updateAndTranslate` method will detect if it is the default language and update accordingly.

Documentation
-------------

[](#documentation)

To get started follow the installation instructions below.

### Installation

[](#installation)

You can install the package via composer:

```
composer require signifly/laravel-translator
```

The package will automatically register itself.

You can publish the migration with:

```
php artisan vendor:publish --tag="translator-migrations"
```

*Note*: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the migration accordingly.

```
php artisan migrate
```

You can optionally publish the config file with:

```
php artisan vendor:publish --tag="translator-config"
```

This is the contents of the published config file:

```
return [

    /*
     * The active language code that is used by the package
     * to return the correct language for a model.
     */
    'active_language_code' => null,

    /*
     * By default the package will not translate model attributes automatically.
     * It should be used with caution as it performs extra requests.
     * Remember to eager load the translations
     * in order to optimize performance.
     */
    'auto_translate_attributes' => false,

    /*
     * The default language code that is used by the package
     * to make comparisons against other languages
     * in order to provide statistics.
     */
    'default_language_code' => 'en',

    /*
     * By default the package will use the `lang` paramater
     * to set the active language code.
     */
    'language_parameter' => 'lang',

    /*
     * This determines if the translations can be soft deleted.
     */
    'soft_deletes' => false,

    /*
     * This is the name of the table that will be created by the migration and
     * used by the Translation model shipped with this package.
     */
    'table_name' => 'translations',

    /*
     * This model will be used to store translations.
     * It should be implements the Signifly\Translator\Contracts\Translation interface
     * and extend Illuminate\Database\Eloquent\Model.
     */
    'translation_model' => \Signifly\Translator\Models\Translation::class,

];
```

### Advanced

[](#advanced)

The package comes with a couple of middlewares that you might want to apply in order to get some extra functionality.

#### Auto Translation

[](#auto-translation)

You can enable this either by setting the `auto_translate_attributes` to `true` in the config or applying the `Signifly\Translator\Http\Middleware\AutoTranslate` middleware to your routes.

For this to work you would also have to set the `active_language_code` in the config.

#### Activate Language

[](#activate-language)

This can inferred from the request if you apply the `Signifly\Translator\Http\Middleware\ActivateLanguage` middleware to your routes.

However, you may also accomplish this manually by calling `Translator::activateLanguage('en')`.

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Morten Poul Jensen](https://github.com/pactode)
- [All contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 97.8% 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 ~86 days

Recently: every ~339 days

Total

21

Last Release

904d ago

Major Versions

v0.0.14 → v1.0.02019-09-09

v1.1.3 → v2.0.02023-11-21

PHP version history (3 changes)v0.0.1PHP ^7.1

v1.1.0PHP ^7.2.5

v1.1.3PHP ^7.2.5|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd06d3bd4452ca3ce5c956b4c0bcb1240ca692f590bc4cdabe104fd07156e0bf?d=identicon)[signifly](/maintainers/signifly)

---

Top Contributors

[![pactode](https://avatars.githubusercontent.com/u/5956778?v=4)](https://github.com/pactode "pactode (91 commits)")[![connors511](https://avatars.githubusercontent.com/u/527889?v=4)](https://github.com/connors511 "connors511 (1 commits)")[![Razorsheep](https://avatars.githubusercontent.com/u/459217?v=4)](https://github.com/Razorsheep "Razorsheep (1 commits)")

---

Tags

eloquenteloquent-modelslaraveltranslation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/signifly-laravel-translator/health.svg)

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

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[ryangjchandler/orbit

A flat-file database driver for Eloquent.

922256.2k5](/packages/ryangjchandler-orbit)[clickbar/laravel-magellan

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

423715.4k1](/packages/clickbar-laravel-magellan)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[baril/bonsai

An implementation of the Closure Tables pattern for Eloquent.

3593.5k](/packages/baril-bonsai)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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