PHPackages                             escapework/laravel-translations - 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. escapework/laravel-translations

ActiveLibrary[Localization &amp; i18n](/categories/localization)

escapework/laravel-translations
===============================

Package to help you easily translate your laravel models

0.1.0(9y ago)263MITPHPPHP &gt;=5.5.0

Since Apr 21Pushed 9y ago3 watchersCompare

[ Source](https://github.com/EscapeWork/laravel-translations)[ Packagist](https://packagist.org/packages/escapework/laravel-translations)[ RSS](/packages/escapework-laravel-translations/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Laravel Translations
====================

[](#laravel-translations)

[![StyleCI Status](https://camo.githubusercontent.com/0117f927709c433aa221d55638dc0319b1e6fd56c98b047a4dfbcce895213e75/68747470733a2f2f7374796c6563692e696f2f7265706f732f35353337313233312f736869656c64)](https://styleci.io/repos/55371231) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![Latest Stable Version](https://camo.githubusercontent.com/adbf3d088b5c597513e70f3aeab3e66e9b4e308850b0ea764c5cf11583995ef7/68747470733a2f2f706f7365722e707567782e6f72672f657363617065776f726b2f6c61726176656c2d7472616e736c6174696f6e732f762f737461626c652e706e67)](https://packagist.org/packages/escapework/laravel-translations) [![Total Downloads](https://camo.githubusercontent.com/8d122eaaa94ee4919fd3c863df082d0d64d6fb9cddcafa8fd251f40f45ec9504/68747470733a2f2f706f7365722e707567782e6f72672f657363617065776f726b2f6c61726176656c2d7472616e736c6174696f6e732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/escapework/laravel-translations)

Easily translate your laravel models to as many languages you need.

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

[](#installation)

Add this line to your `composer.json` file:

```
    "escapework/laravel-translations": "0.2.*"

```

And add this service provider to your laravel providers:

```
    EscapeWork\Translations\TranslationServiceProvider::class
```

And publish the migrations running the following command:

```
$ php artisan vendor:publish --provider="EscapeWork\Translations\TranslationServiceProvider"
$ php artisan migrate
```

Usage
-----

[](#usage)

### Creating the locales

[](#creating-the-locales)

First, you need to create the locales that your models will be translated.

```
EscapeWork\Translations\Locale::create(['id' => 'pt-br', 'title' => 'Português (Brasil)']);
EscapeWork\Translations\Locale::create(['id' => 'en',    'title' => 'English']);
```

Then, you need to import the `Translatable` in your models.

```
use EscapeWork\Translations\Translatable;
...

class Product extends Model
{

    use Translatable;
}
```

### Storing a translation

[](#storing-a-translation)

For storing a translation, you can do the following:

```
// $data can have as many fields you want
$data = [
    'title'       => 'My translated title',
    'description' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
];

$product->storeTranslation((array) $data, 'pt-br');
```

Here it's an example on how you can use with Laravel `$request` object.

```
$product = Product::find(1);

foreach ((array) $request->translations as $locale => $data) {
    $product->storeTranslation((array) $data, $locale);
}
```

### Deleting translations from a model

[](#deleting-translations-from-a-model)

```
$product->deleteTranslations();
```

### Getting a translation

[](#getting-a-translation)

For getting an existing translation, you just need to do this:

```
$product = Product::find(1);
echo $product->translations->_get('title'); // this will get the translation for the current config('app.locale') value
```

If you need an translation for an specific locale, just pass the locale as the second argument:

```
$product = Product::find(1);
echo $product->translations->_get('title', 'pt-br');
```

If you don't pass the `$locale`, the default is gonna be the `config('app.locale')` value.

You can also do something like this to make your life easier:

```
class Product extends Model
{
    ...
    public function getTitleAttribute()
    {
        return $this->translations->_get('title');
    }
    ...
}

// then, just call like a simple field
echo $product->title;
```

Next steps
----------

[](#next-steps)

- Testing;
- Make use of MySQL 5.7 JSON types, where a search inside the translations will be available;

License
-------

[](#license)

See the [License](https://github.com/EscapeWork/laravel-translations/blob/master/LICENSE) file.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3557d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57e405b52d482c9de35b17f299d2745e8e68d9d9951aec64854f2d7fa53110bf?d=identicon)[luisdalmolin](/maintainers/luisdalmolin)

---

Top Contributors

[![luisdalmolin](https://avatars.githubusercontent.com/u/403446?v=4)](https://github.com/luisdalmolin "luisdalmolin (32 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/escapework-laravel-translations/health.svg)

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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