PHPackages                             shanginn/yalt - 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. shanginn/yalt

ActiveLibrary

shanginn/yalt
=============

Yet Another Laravel Translator for Eloquent models (Yalt)

12.1kPHP

Since Sep 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/shanginn/Yet-Another-Laravel-Translator)[ Packagist](https://packagist.org/packages/shanginn/yalt)[ RSS](/packages/shanginn-yalt/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Yet Another Laravel Translator
==============================

[](#yet-another-laravel-translator)

*Warning: this package is actively developed, be careful*

Requires
--------

[](#requires)

- PHP 7.\*
- Laravel 5.\* (Only tested with 5.4)

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

[](#installation)

### Package

[](#package)

```
composer require shanginn/yalt
```

Add the service provider to **config/app.php**

```
'providers' => [
	//...
	Shanginn\Yalt\YaltServiceProvider::class,
]
```

### Migrations

[](#migrations)

By default suffix for translatable table is set to `ll`, so for example translations table for `things` table should be named `things_lls`.

You can change this suffix in the config file (*translation\_suffix*).

```
php artisan make:migration create_things_localizations_table
```

Let's assume you need translatable title and description for the `Thing`. Open up your migration and edit `up` method like this:

```
// database/migrations/2017_02_20_200652_create_things_localizations_table.php

public function up()
{
	Schema::create('things_lls', function (Blueprint $table) {
		$table->increments('id');
		$table->char('locale', 2)->index();
		$table->integer('thing_id')->index();
		$table->string('title');
		$table->string('description');

		$table->unique(['thing_id', 'locale']);

		$table->foreign('thing_id', 'thing_idx')
			->references('id')->on('things')
			->onDelete('cascade')
			->onUpdate('cascade');
	});
}
```

### Model

[](#model)

All you need to do to make `Thing` model translatable is to import Translatable trait, use it and define translatable fields.

```
// App/Thing.php
//...
use Shanginn\Yalt\Eloquent\Concerns\Translatable;

class Thing extends Model
{
	use Translatable;

	protected $translatable = ['title', 'description'];
//...
```

That's it! No models, no relations. Pure magic.

### Middleware

[](#middleware)

If you want to change current app locale based on 'Accept-Language' header, register `locale` [middleware](laravel.com/docs/5.4/middleware) in the `Http/Kernel.php`.

```
// Http/Kernel.php
//...
protected $routeMiddleware = [
//...
	'locale' => \Shanginn\Yalt\Http\Middleware\Localization::class,
//...
]
```

And apply it to some routes.

Usage
-----

[](#usage)

```
Thing::create([
	'title' => [ // Explicit locale definition for title
		'en' => 'Title in english',
		'ru' => 'Русский заголовок'
	],
	// Use default locale for description
	'description' => 'Description in the default locale'
])
```

*Sorry. That's it for now. More info coming... Take a look into sources.*

TODO
----

[](#todo)

- Write basic info here
- Write more info here
- Create tests
- Test all provided functional
- Add artisan command to create migrations for Translatable models
- Replace `id` PK with \[`item_id`, `locale`\] composite PK in \_lls table
- Add ability to choose between *plural* and *single* table suffix (ex. things\_lls vs thing\_lls)

Additional info
---------------

[](#additional-info)

Based on [dimsav/laravel-translatable](https://github.com/dimsav/laravel-translatable). But I was too lazy to create the same model for every translatable thing so I rewrote this package almost completely.

Feel free to contribute in any way!

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/311e425711f60c09486c23252696fbe4dfa77e9b0dd5517bc89b288ac2f58655?d=identicon)[shanginn](/maintainers/shanginn)

---

Top Contributors

[![shanginn](https://avatars.githubusercontent.com/u/3357943?v=4)](https://github.com/shanginn "shanginn (37 commits)")

### Embed Badge

![Health badge](/badges/shanginn-yalt/health.svg)

```
[![Health](https://phpackages.com/badges/shanginn-yalt/health.svg)](https://phpackages.com/packages/shanginn-yalt)
```

PHPackages © 2026

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