PHPackages                             visual-ideas/moonshine-spatie-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. visual-ideas/moonshine-spatie-translatable

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

visual-ideas/moonshine-spatie-translatable
==========================================

Spatie\\Translatable field for MoonShine Laravel admin panel

3.1.0(2w ago)76.8k↑38.5%31MITPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

Since Apr 12Pushed 2w ago1 watchersCompare

[ Source](https://github.com/visual-ideas/moonshine-spatie-translatable)[ Packagist](https://packagist.org/packages/visual-ideas/moonshine-spatie-translatable)[ Docs](https://moonshine.cutcode.dev/section/fields-spatie-translatable)[ RSS](/packages/visual-ideas-moonshine-spatie-translatable/feed)WikiDiscussions 3.x Synced 2w ago

READMEChangelog (10)DependenciesVersions (26)Used By (1)

Spatie\\Translatable field for [MoonShine Laravel admin panel](https://moonshine-laravel.com)
=============================================================================================

[](#spatietranslatable-field-for-moonshine-laravel-admin-panel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/809f39706b52c2e5984d88de845416856416cb975cbe6e82d387e3fdadeb204c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76697375616c2d69646561732f6d6f6f6e7368696e652d7370617469652d7472616e736c617461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/visual-ideas/moonshine-spatie-translatable)[![Total Downloads](https://camo.githubusercontent.com/66bfd6fdee92c2f22ea802295b606a26bae9936aac49c1a459d47138ff49c798/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76697375616c2d69646561732f6d6f6f6e7368696e652d7370617469652d7472616e736c617461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/visual-ideas/moonshine-spatie-translatable)

Extends the MoonShine [JSON](https://moonshine-laravel.com/ru/docs/4.x/fields/json) field to work with [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable). Provides a full interface for editing multi-language model attributes inside MoonShine resources.

Compatibility
-------------

[](#compatibility)

MoonShinePackageSupported&gt;= v1.0^1.0no&gt;= v2.0^2.0yes&gt;= v3.0^3.0yes&gt;= v4.0^3.0yesInstallation
------------

[](#installation)

**This field belongs to a separate package — complete installation before using it.**

```
composer require "visual-ideas/moonshine-spatie-translatable:^3.0"
```

> For MoonShine 2.\* use `^2.0` instead.

The package registers automatically via Laravel's package auto-discovery. If you have disabled auto-discovery, register the service provider manually:

```
// config/app.php
'providers' => [
    VI\MoonShineSpatieTranslatable\ServiceProvider::class,
],
```

> For Laravel 11+, add `VI\MoonShineSpatieTranslatable\ServiceProvider::class` to `bootstrap/providers.php` instead.

### Requirements

[](#requirements)

- PHP 8.0–8.5
- MoonShine &gt;= 3.0
- [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) installed and configured
- The model attribute must be in the `$translatable` array

### Assets

[](#assets)

Publish assets for the compact mode styles:

```
php artisan vendor:publish --tag=moonshine-spatie-translatable-assets
```

Basic usage
-----------

[](#basic-usage)

```
use VI\MoonShineSpatieTranslatable\Fields\Translatable;

// In your MoonShine resource fields() method:
Translatable::make('Title', 'name')
```

The field renders as a key-value JSON list where each row has a language code (Select) and a value (Text input by default).

> ⚠️ The `onlyValue()` method (inherited from the parent `Json` field) is **not supported** — translatable fields always require both a language key and a value.

How it works
------------

[](#how-it-works)

The field integrates with [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) at the model level:

1. **Storage** — Spatie stores all translations as a JSON object in a single database column (e.g., `{"lv": "Nosaukums", "en": "Title", "ru": "Название"}`)
2. **Reading** — The field calls `$model->getTranslations('column')` to retrieve existing translations and converts them into key-value pairs for the form (`[{key: 'lv', value: 'Nosaukums'}, ...]`)
3. **Saving** — On form submit, the field converts the key-value pairs back into a translations array and calls `$model->replaceTranslations('column', [...])`

The underlying UI is MoonShine's [Json field](https://moonshine-laravel.com/docs/4.x/fields/json) with a language code `Select` and a value input.

Language configuration
----------------------

[](#language-configuration)

### `languages(array $codes)`

[](#languagesarray-codes)

Restrict the language list to specific codes. By default ~120 common locale codes are available.

```
Translatable::make('Title', 'name')
    ->languages(['lv', 'en', 'ru'])
```

### `requiredLanguages(array $codes)`

[](#requiredlanguagesarray-codes)

Languages to place at the very top of the list, before `priorityLanguages`. Useful for highlighting important locales.

```
Translatable::make('Title', 'name')
    ->requiredLanguages([config('app.fallback_locale')])
```

### `priorityLanguages(array $codes)`

[](#prioritylanguagesarray-codes)

Bring certain languages to the top of the list in the form.

```
Translatable::make('Title', 'name')
    ->priorityLanguages([
        config('app.fallback_locale'),
        config('app.locale'),
        'de', 'fr',
    ])
```

> Merge order: `requiredLanguages` first, then `priorityLanguages`, then all `languages`.

Input field type
----------------

[](#input-field-type)

By default the value input is a single-line `Text` field. You can switch to other field types.

### `textarea()`

[](#textarea)

```
Translatable::make('Description', 'description')
    ->textarea()
```

### `tinyMce()`

[](#tinymce)

Requires `moonshine/tinymce` package.

```
Translatable::make('Body', 'body')
    ->tinyMce()
```

### `json()`

[](#json)

```
Translatable::make('Metadata', 'metadata')
    ->json()
```

### `customInputField(string $fieldClass)`

[](#custominputfieldstring-fieldclass)

Any MoonShine field class that extends `MoonShine\UI\Fields\Field`.

```
Translatable::make('Code', 'code')
    ->customInputField(CodeField::class)
```

Compact mode
------------

[](#compact-mode)

The field can render as a **compact tabbed interface** — language badges at the top, one visible editor at a time.

```
Translatable::make('Title', 'name')
    ->compact()
```

Features:

- Language badges with active state highlighting
- Add new languages from a dropdown (shows only unselected languages)
- Supports any input type (Text, Textarea, TinyMCE, etc.)
- Syncs values on language switch — no data loss when switching between tabs
- Hidden inputs for all languages render for form submission

Removing translations
---------------------

[](#removing-translations)

The `removable()` method works in **both modes** (default key-value and compact). It adds a remove button to each translation row.

```
Translatable::make('Field', 'field')
    ->removable()
```

> ⚠️ If you leave the translation text blank, it will be deleted on save. If there are two translations for the same language, the first one is removed (replaced).

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md) for more information.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 61.5% 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

Every ~52 days

Recently: every ~138 days

Total

24

Last Release

20d ago

Major Versions

0.0.1 → 1.0.02023-04-12

1.x-dev → 2.0.02023-11-22

2.2.1 → 3.0.02025-01-19

2.x-dev → 3.0.12025-02-01

PHP version history (3 changes)0.0.0PHP ^8.0|^8.1|^8.2

3.0.1PHP ^8.0|^8.1|^8.2|^8.3|^8.4

3.1.0PHP ^8.0|^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12836836?v=4)[AlexVenga](/maintainers/AlexVenga)[@alexvenga](https://github.com/alexvenga)

---

Top Contributors

[![alexvenga](https://avatars.githubusercontent.com/u/12836836?v=4)](https://github.com/alexvenga "alexvenga (32 commits)")[![Ge1i0N](https://avatars.githubusercontent.com/u/6265043?v=4)](https://github.com/Ge1i0N "Ge1i0N (10 commits)")[![SWEET1S](https://avatars.githubusercontent.com/u/84906111?v=4)](https://github.com/SWEET1S "SWEET1S (6 commits)")[![lee-to](https://avatars.githubusercontent.com/u/1861327?v=4)](https://github.com/lee-to "lee-to (3 commits)")[![sq-dev](https://avatars.githubusercontent.com/u/79777081?v=4)](https://github.com/sq-dev "sq-dev (1 commits)")

---

Tags

laravelmoonshinephpspatiespatie-laravel-translatablespatie-translatabletranslatetranslationvivisualideasphpspatielaraveltranslatetranslatabledictionarymoonshineviVisualIdeasspatie-translatableSpatie Laravel Translatable

### Embed Badge

![Health badge](/badges/visual-ideas-moonshine-spatie-translatable/health.svg)

```
[![Health](https://phpackages.com/badges/visual-ideas-moonshine-spatie-translatable/health.svg)](https://phpackages.com/packages/visual-ideas-moonshine-spatie-translatable)
```

###  Alternatives

[outl1ne/nova-translatable

A laravel-translatable extension for Laravel Nova.

203486.1k11](/packages/outl1ne-nova-translatable)[optimistdigital/nova-translatable

A laravel-translatable extension for Laravel Nova.

202466.3k5](/packages/optimistdigital-nova-translatable)[visual-ideas/moonshine-spatie-medialibrary

Spatie\\MediaLibrary field for MoonShine Laravel admin panel

2018.6k](/packages/visual-ideas-moonshine-spatie-medialibrary)[mvenghaus/filament-plugin-translatable-inline

An alternative to https://github.com/filamentphp/spatie-laravel-translatable-plugin. The difference is that all translations occur directly under each field.

2257.4k](/packages/mvenghaus-filament-plugin-translatable-inline)[tomatophp/filament-translations

Manage your translation with DB and cache, you can scan your languages tags like trans(), \_\_(), and get the string inside and translate them use UI.

6437.6k3](/packages/tomatophp-filament-translations)[happenv-com/filament-translatable

Highly customizable Translation component for Filament PHP.

101.4k](/packages/happenv-com-filament-translatable)

PHPackages © 2026

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