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

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

slivka-b/laravel-translatable
=============================

\[fork\] The package provides possibility to translate your Eloquent models into different languages using a single database table.

0.1.1(3y ago)02361MITPHPPHP ^8.0

Since Mar 21Pushed 3y agoCompare

[ Source](https://github.com/SviatoslavBereznitskyi/laravel-translatable)[ Packagist](https://packagist.org/packages/slivka-b/laravel-translatable)[ Docs](https://github.com/nevadskiy/laravel-translatable)[ RSS](/packages/slivka-b-laravel-translatable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (1)

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

[](#laravel-translatable)

**This package is a fork of nevadskiy/laravel-translatable.**

[![Tests](https://github.com/nevadskiy/laravel-translatable/workflows/Tests/badge.svg)](https://packagist.org/packages/nevadskiy/laravel-translatable)[![Code Coverage](https://camo.githubusercontent.com/3efa3b3ccd9527bea826198f8efd619ea2047c3aaf3965854b3061566e4574ef/68747470733a2f2f636f6465636f762e696f2f67682f6e65766164736b69792f6c61726176656c2d7472616e736c617461626c652f6272616e63682f6d61737465722f6772617068732f62616467652e7376673f6272616e63683d6d6173746572)](https://packagist.org/packages/nevadskiy/laravel-translatable)[![License](https://camo.githubusercontent.com/fd98116a1d78388464aa86b480e9798dc79330ab307da1dd14bc76d0ec41802f/68747470733a2f2f706f7365722e707567782e6f72672f6e65766164736b69792f6c61726176656c2d7472616e736c617461626c652f6c6963656e7365)](https://packagist.org/packages/nevadskiy/laravel-translatable)[![Latest Stable Version](https://camo.githubusercontent.com/ae00bb13f01a794f917f872f7d4bb0b04f369f03aba6cb20c61bdbe013740892/68747470733a2f2f706f7365722e707567782e6f72672f6e65766164736b69792f6c61726176656c2d7472616e736c617461626c652f76)](https://packagist.org/packages/nevadskiy/laravel-translatable)

The package provides possibility to translate your Eloquent models into different languages using a single database table.

🍬 Features
----------

[](#-features)

- Auto-resolving model translations for the current locale.
- No need to rewrite existing migrations, models or views.
- Store all translations in the single 'translations' table.
- Works with model accessors &amp; mutators &amp; casts, even with JSON.
- Works with route model binding.
- Archive translations to improve searching experience.
- Provides useful events.

⚙️ Demo
-------

[](#️-demo)

```
$book = Book::create(['title' => 'Book about giraffes']);

// Storing translations
app()->setLocale('es');
$book->title = 'Libro sobre jirafas';
$book->save();

// Reading translations
app()->setLocale('es');
echo $book->title; // 'Libro sobre jirafas'

app()->setLocale('en');
echo $book->title; // 'Book about giraffes'
```

✅ Requirements
--------------

[](#-requirements)

- Laravel `9.0` or newer
- PHP `8.0` or newer

🔌 Installation
--------------

[](#-installation)

1. Install the package via composer.

```
composer require imcity-tech/laravel-translatable
```

2. Optional. If you are not going to use translations for models with UUID primary keys, make the following:

- Publish package migration

```
php artisan vendor:publish --tag=translatable
```

- Replace the line `$table->uuidMorphs('translatable');` with `$table->morphs('translatable');` in the published migration.

3. Run the migration command.

```
php artisan migrate
```

🔨 Making models translatable
----------------------------

[](#-making-models-translatable)

1. Add the `HasTranslations` trait to your models which you want to make translatable.

```
