PHPackages                             wakjoko/localizable - 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. wakjoko/localizable

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

wakjoko/localizable
===================

Transform any Eloquent attribute as multi language

0.1.0(2y ago)03MITPHPPHP ^8.0

Since Aug 8Pushed 2y ago1 watchersCompare

[ Source](https://github.com/wakjoko/localizable)[ Packagist](https://packagist.org/packages/wakjoko/localizable)[ Docs](https://github.com/wakjoko/localizable)[ RSS](/packages/wakjoko-localizable/feed)WikiDiscussions master Synced today

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

Localized language translation made simple yet elegant
======================================================

[](#localized-language-translation-made-simple-yet-elegant)

[![Latest Version on Packagist](https://camo.githubusercontent.com/36c7862e0590abe8496048df611c4cd59d211a274b23e6da50c48339b0daba40/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77616b6a6f6b6f2f6c6f63616c697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wakjoko/localizable)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/fdce3ca2ad9bce21a80524825a48888e13f866f9e58f525f4df03d87a71ab69c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77616b6a6f6b6f2f6c6f63616c697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wakjoko/localizable)

Transform any Eloquent attribute as multi language.
I found [spatie's translation package](https://github.com/spatie/laravel-translatable) is super awesome but it's lack of query flexibility makes me ichy to build this package instead.

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

[](#installation)

Install the package via composer:

```
composer require wakjoko/localizable
```

Create the table for data storage:

```
php artisan migrate
```

Setting Up
----------

[](#setting-up)

Enable model localization with below:

```
class Person extends Model
{
    use \Wakjoko\Localizable\Localizable;

    protected $localizable = ['name', 'title', 'gender'];
}
```

Use custom db connection or table name:

```
LOCALIZABLE_DB=mysql
LOCALIZABLE_TABLE=multilanguage
```

What would you get?
-------------------

[](#what-would-you-get)

#### Preload localized language translation

[](#preload-localized-language-translation)

```
$person = Person::withLocalizable()->find(1);
$person = Person::withLocalizable()->first();
$persons = Person::withLocalizable()->get();
$persons = Person::withLocalizable()->paginate();
```

#### Narrow down Person results based on localized language translation

[](#narrow-down-person-results-based-on-localized-language-translation)

```
// find anyone with he's name in english contains "john"
$models = Person::withLocalizable(
        attribute: 'name',
        locale: 'en',
        value: 'john'
    )
    ->get();
```

#### Creating, updating localized language translation

[](#creating-updating-localized-language-translation)

```
// insert new data along with localized language translation
$person = Person::create([
    'name' => [
        'ms' => 'Nuh',
        'en' => 'Noah'
    ]
]);

// another way of creating new data
$person = new Person([
    'name' => [
        'ms' => 'Nuh',
        'en' => 'Noah'
    ]
]);
$person->save();

// change my english name
$person->name('en', 'Charlie');
$person->save();

// or update via attribute
$person->name = [
    'ms' => 'Nuh',
    'en' => 'Noah'
];
$person->save();

// or use update() instead of save()
$person->update(['name' => ['en' => 'John']]);
```

#### Switch locale

[](#switch-locale)

```
$person->name               // prints Noah: use default lang in config('app.locale')
$person->setLocale('ms');   // switch language only on this model
$person->name               // prints: Nuh
$person->name('en');        // prints Noah: another way to get localized translation without changing default lang on the model
```

#### Localizable data are also inspectable in Tinker

[](#localizable-data-are-also-inspectable-in-tinker)

```
App\Models\Person {#10328
    id: 1,
    name: [
      "en" => "Noah",
      "ms" => "Nuh",
    ],
  }
```

### Testing

[](#testing)

```
naah.. nothing yet haha!
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please mail to  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Spatie Translatable](https://github.com/spatie/laravel-translatable)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1060d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/26d99fbe4404013c5f3f858859bc1517cb0911afc643df1de193b3ca0734859d?d=identicon)[wakjoko](/maintainers/wakjoko)

---

Top Contributors

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

---

Tags

laraveli18nlanguagetranslatedatabasemodeleloquentmultilingualdblocalemorphpolymorphicpolyglotlocalizable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wakjoko-localizable/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M94](/packages/mongodb-laravel-mongodb)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

592456.3k2](/packages/spiritix-lada-cache)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M1](/packages/glushkovds-phpclickhouse-laravel)[omaralalwi/lexi-translate

Laravel translation package with morph relationships and caching.

7413.7k5](/packages/omaralalwi-lexi-translate)

PHPackages © 2026

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