PHPackages                             tonsoo/filament-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. tonsoo/filament-translatable

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

tonsoo/filament-translatable
============================

Simple translatable models and Filament form helpers for Laravel.

0.1.0(1mo ago)021↓100%MITPHPPHP ^8.3CI passing

Since Apr 24Pushed 1mo agoCompare

[ Source](https://github.com/tonsoo/filament-translatable)[ Packagist](https://packagist.org/packages/tonsoo/filament-translatable)[ RSS](/packages/tonsoo-filament-translatable/feed)WikiDiscussions main Synced 1w ago

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

Filament Translatable
=====================

[](#filament-translatable)

Model and Filament page traits for runtime translations.

[![Latest Version on Packagist](https://camo.githubusercontent.com/ed17ae737f5b2dd8b940542c4d52e64a0e066b48ea88d888e48f04b09338899e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6e736f6f2f66696c616d656e742d7472616e736c617461626c652e737667)](https://packagist.org/packages/tonsoo/filament-translatable)[![Tests](https://camo.githubusercontent.com/b26789e82bd982d8a41a829794e21851dcf709ad2d8e2563b602659db24a3f35/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f6e736f6f2f66696c6573697a652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://github.com/tonsoo/filament-translatable/actions)[![License](https://camo.githubusercontent.com/8e6199a9a2ea4d9672d31469bd061b810ed98ada6ba6276cce1b3d5ff31378e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746f6e736f6f2f66696c6573697a652e737667)](https://github.com/tonsoo/filament-translatable/blob/main/LICENSE)

---

Locale discovery uses `getTranslatableLocales()` or the static `$translatableLocales` property when present, then `app.available_locales` (or `app.locales`), and finally the current app locale. Fallback translation uses `app.fallback_locale` when set.

Supported Versions
------------------

[](#supported-versions)

- PHP: `^8.3`
- Laravel: `^13.0`
- Filament: `^5.0`
- Livewire: `^4.1`

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

[](#installation)

```
composer require tonsoo/filament-translatable
```

Model Trait
-----------

[](#model-trait)

```
use Illuminate\Database\Eloquent\Model;
use Tonsoo\FilamentTranslatable\Concerns\HasTranslations;

class Post extends Model
{
    use HasTranslations;

    protected array $translatable = ['title', 'content'];
}
```

Translatable attributes must be JSON columns.

Filament Page Trait
-------------------

[](#filament-page-trait)

Use the page trait in your own create/edit pages:

```
use Filament\Resources\Resource;

class ProductResource extends Resource
{
    protected static ?string $model = Product::class;

    public static function getTranslatableLocales(): array // optional
    {
        return (array) config('app.available_locales', []);
    }
}
```

`InteractsWithTranslatableResourceData` reads translatable attributes from the model. Form inputs are scalar in the UI, and the trait converts translatable fields into locale maps for persistence.

Optional Runtime Locale Switcher
--------------------------------

[](#optional-runtime-locale-switcher)

Add this resource trait to render a locale select beside the page heading:

```
use Tonsoo\FilamentTranslatable\Resources\Concerns\HasTranslatableLocaleSwitcher;

class ProductResource extends Resource
{
    use HasTranslatableLocaleSwitcher;

    protected static ?string $model = Product::class;

    public static function getTranslatableLocales(): array
    {
        return (array) config('app.available_locales', []);
    }

    protected static string $defaultTranslatableLocale = 'en'; // optional
    protected static array $translatableLocaleLabels = [ // optional
        'en' => 'English',
        'es' => 'Spanish',
    ];
}
```

You can also define the locale list with a static `protected array $translatableLocales = [...]` property instead of overriding `getTranslatableLocales()`. The locale labels array is optional; if you omit it, the switcher uses the locale code as the label. `protected static string $defaultTranslatableLocale = 'en';` is optional and is used only when it matches one of the configured locales.

```
use App\Filament\Resources\ProductResource;
use Filament\Resources\Pages\CreateRecord;
use Filament\Resources\Pages\EditRecord;
use Tonsoo\FilamentTranslatable\Resources\Pages\Concerns\InteractsWithTranslatableResourceData;

class CreateProduct extends CreateRecord
{
    use InteractsWithTranslatableResourceData;

    protected static string $resource = ProductResource::class;
}

class EditProduct extends EditRecord
{
    use InteractsWithTranslatableResourceData;

    protected static string $resource = ProductResource::class;
}
```

This automatically wires:

- `mutateFormDataBeforeFill()` on edit pages
- `mutateFormDataBeforeCreate()` on create pages
- `mutateFormDataBeforeSave()` on edit pages

Model API
---------

[](#model-api)

```
$post->setTranslation('title', 'en', 'Hello');
$post->setTranslation('title', 'es', 'Hola');

$post->getTranslation('title', 'en');
$post->getTranslation('title', 'es'); // fallback uses app.fallback_locale
$post->getTranslations('title');

$post->title = 'Hello'; // current locale
$post->{'title.es'} = 'Hola'; // explicit locale
```

Locale-Aware Query Columns
--------------------------

[](#locale-aware-query-columns)

When querying translatable attributes, the package maps plain translatable column names to the current locale JSON path.

```
app()->setLocale('pt_BR');

Post::query()->where('title', '=', 'Teste');
// same intent as querying: title->pt_BR = 'Teste'
```

You can also pass explicit locale dot notation:

```
Post::query()->where('title.pt_BR', '=', 'Teste');
```

Disable this behavior per query:

```
Post::query()
    ->withoutAutoTranslationsQuery()
    ->where('title->en', '=', 'Hello');
```

Re-enable later in the same chain:

```
Post::query()
    ->where('title', 'Teste')
    ->withoutAutoTranslationsQuery()
    ->where('title->en', 'Hello')
    ->withAutoTranslationsQuery()
    ->where('title', 'Teste');
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

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

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32c5f40ac08285ef9e848f0d7bc76d30cc427d3670c272e3b1151e0724a85898?d=identicon)[tonsoo](/maintainers/tonsoo)

---

Top Contributors

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

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/tonsoo-filament-translatable/health.svg)

```
[![Health](https://phpackages.com/badges/tonsoo-filament-translatable/health.svg)](https://phpackages.com/packages/tonsoo-filament-translatable)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[rapidez/core

Rapidez Core

1822.4k65](/packages/rapidez-core)

PHPackages © 2026

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