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

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

said/laravel-translatable
=========================

This is a Laravel package containing a trait for translatable Eloquent models. This package follows the approach to have only a single table to maintain all the translations.

0.03(3y ago)275↓100%MITPHPPHP &gt;=7.1

Since Apr 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ibrahim-Said/laravel-translatable)[ Packagist](https://packagist.org/packages/said/laravel-translatable)[ RSS](/packages/said-laravel-translatable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (9)Used By (0)

A Trait to handle Translations in Laravel
=========================================

[](#a-trait-to-handle-translations-in-laravel)

This is a Laravel package containing a trait for translatable Eloquent models. This package follows the approach to have only a single table to maintain all the translations.

This approach may not be perfect for every use case as the table can grow really big. But compared to all the other packages this approach is the most flexible as it lets you make models and its attributes translatable without extra configuration.

Alternatives to this package are following packages:

1. [Spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) saves the translatable attributes as jsons
2. [dimsav/laravel-translatable](https://github.com/dimsav/laravel-translatable) expects a new table for every new model that has translatable attributes

Requirements
------------

[](#requirements)

This package require a minimum Laravel version of `5.8` and PHP in version `7.1`

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

[](#installation)

You can install the package via composer:

```
composer require said/laravel-translatable:0.0.7
```

Now you can use this Trait on any Eloquent Model of your project.

Usage
-----

[](#usage)

To make your Eloquent Model translatable just add the Said\\Translatable\\Traits\\Translatable`Trait to your model. Then add a public attribute`$translatable\_columns` as an array containing all the attributes that should be translatable.

```
