PHPackages                             kkhomeriki/nova-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. kkhomeriki/nova-translatable

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

kkhomeriki/nova-translatable
============================

Making Nova fields translatable

3.0.1(6y ago)00MITPHPPHP &gt;=7.2.0

Since Oct 8Pushed 6y agoCompare

[ Source](https://github.com/KhomerikiK/nova-translatable)[ Packagist](https://packagist.org/packages/kkhomeriki/nova-translatable)[ Docs](https://github.com/spatie/nova-translatable)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/kkhomeriki-nova-translatable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (14)Used By (0)

Making Nova fields translatable
===============================

[](#making-nova-fields-translatable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0046815980e9826ccb2dfd241c6920acc7a09509b41c56b5ac8279fcfe7e4e78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6e6f76612d7472616e736c617461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/nova-translatable)[![StyleCI](https://camo.githubusercontent.com/e493984be66ce460f971dac967f86db038d47f66e8ec549d1bb77e144155418d/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135303132373731322f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/150127712)[![Total Downloads](https://camo.githubusercontent.com/cf44815d37a522aa13cb70f18b19a39f8a9bb232aa01630379fb486446ad110f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6e6f76612d7472616e736c617461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/nova-translatable)

This package contains a `Translatable` class you can use to make any Nova field type translatable.

Imagine you have this `fields` method in a `Post` Nova resource:

```
public function fields(Request $request)
{
    return [
        ID::make()->sortable(),

        Translatable::make([
            Text::make('title'),
            Trix::make('text'),
        ]),
    ];
}
```

That `Post` Nova resource will be rendered like this.

[![screenshot](https://camo.githubusercontent.com/ebf7d223ee8bc12174cdcc1cd3bd4ee18ee970b0f6e1735396fd46803a08e080/68747470733a2f2f7370617469652e6769746875622e696f2f6e6f76612d7472616e736c617461626c652f73637265656e73686f742e706e67)](https://camo.githubusercontent.com/ebf7d223ee8bc12174cdcc1cd3bd4ee18ee970b0f6e1735396fd46803a08e080/68747470733a2f2f7370617469652e6769746875622e696f2f6e6f76612d7472616e736c617461626c652f73637265656e73686f742e706e67)

Requirements
------------

[](#requirements)

This Nova field requires Nova 3 specifically and MySQL 5.7.8 or higher.

Support us
----------

[](#support-us)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

First you must install [spatie/laravel-translatable](https://github.com/spatie/laravel-translatable) into your Laravel app. In a nutshell, this package will store translations for your model in a json column in your table. On top of that, it provides many handy functions to store and retrieve translations. Be sure to read [the entire readme of laravel-translatable](https://github.com/spatie/laravel-translatable/blob/master/README.md) before using this Nova package.

Next, you can install this Nova package into a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```
composer require spatie/nova-translatable
```

Usage
-----

[](#usage)

In order to use the package you must first let `Translatable` know which locales your app is using using the `Translatable::defaultLocales()` method. You can put this code in `AppServiceProvider` or a dedicated service provider of your own.

```
// in any service provider

\Spatie\NovaTranslatable\Translatable::defaultLocales(['en', 'fr']);
```

Next, you must prepare your model [as explained](https://github.com/spatie/laravel-translatable#making-a-model-translatable) in the readme of laravel-translatable. In short: you must add `json` columns to your model's table for each field you want to translate. Your model must use the `Spatie\Translatable\HasTranslations` on your model. Finally, you must also add a `$translatable` property on your model that holds an array with the translatable attribute names.

Now that your model is configured for translations, you can use `Translatable` in the related Nova resource. Any fields you want to display in a multilingual way can be passed as an array to `Translatable.

```
public function fields(Request $request)
{
    return [
        ID::make()->sortable(),

        Translatable::make([
            Text::make('title'),
            Trix::make('text'),
        ]),
    ];
}
```

### Customizing the locales per translatable

[](#customizing-the-locales-per-translatable)

If you have a Nova resource where you want different locales than the ones configured globally, you can call the `locales` method on `Translatable`.

```
Translatable::make([
    Text::make('title'),
    Trix::make('text'),
])->locales(['de', 'es']),
```

These fields will now use the `de` and `es` locales.

### Customizing the name of a translatable

[](#customizing-the-name-of-a-translatable)

By default translatable fields get ` ($locale)` appended to their name. You can customize this behaviour globally by providing a closure to `displayLocalizedNameByDefaultUsing` on `Translatable`. This callback will be used to render the localized field names.

```
Translatable::displayLocalizedNameByDefaultUsing(function(Field $field, string $locale) {
   return ucfirst($field->name) . " [{$locale}]";
})
```

With this in place all names of translatable fields will get ` [$locale]` appended.

You can also customize the localized field name per resource by passing a closure the `displayLocalizedNameUsing` function.

```
Translatable::make([
    Text::make('title'),
    Trix::make('text'),
])->displayLocalizedNameUsing(function(Field $field, string $locale) {
   return ucfirst($field->name) . " --- {$locale}]";
}),
```

With this in place, the localized field names will be suffixed with ` --- $locale`.

Of course you can still customize the name of a field as usual.

```
Translatable::make([
    Text::make('My title', 'title'),
    Trix::make('text'),
])->displayLocalizedNameUsing(function(Field $field, string $locale) {
   return ucfirst($field->name) . " [{$locale}]";
}),
```

Using the code about above the name for the `title` field will be "My title \['en'\]".

On customizing the UI
---------------------

[](#on-customizing-the-ui)

You might wonder why we didn't render the translatable fields in tabs, panels or with magical unicorns displayed next to them. The truth is that everybody wants translations to be displayed a bit different. That's why we opted to keep them very simple for now.

If Nova gains the ability to better structure a long form natively, we'd probably start leveraging that in a new major version of the package.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 82% 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 ~48 days

Recently: every ~95 days

Total

12

Last Release

2250d ago

Major Versions

0.0.4 → 1.0.02018-10-24

1.0.1 → 2.0.02019-02-27

2.0.3 → 3.0.02020-03-03

PHP version history (2 changes)0.0.1PHP &gt;=7.1.0

2.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6290ec275136755908a3a3eabe6d3cee9da7f14c65b8733f61908a68d40891a8?d=identicon)[khomerikiKkote](/maintainers/khomerikiKkote)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (50 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![mrmonat](https://avatars.githubusercontent.com/u/17597850?v=4)](https://github.com/mrmonat "mrmonat (1 commits)")[![satoved](https://avatars.githubusercontent.com/u/14319239?v=4)](https://github.com/satoved "satoved (1 commits)")[![stephanedemotte](https://avatars.githubusercontent.com/u/2158130?v=4)](https://github.com/stephanedemotte "stephanedemotte (1 commits)")[![Tarpsvo](https://avatars.githubusercontent.com/u/2018660?v=4)](https://github.com/Tarpsvo "Tarpsvo (1 commits)")[![voidgraphics](https://avatars.githubusercontent.com/u/9298484?v=4)](https://github.com/voidgraphics "voidgraphics (1 commits)")[![dduupp](https://avatars.githubusercontent.com/u/10728938?v=4)](https://github.com/dduupp "dduupp (1 commits)")[![KhomerikiK](https://avatars.githubusercontent.com/u/39499899?v=4)](https://github.com/KhomerikiK "KhomerikiK (1 commits)")

---

Tags

laravelnova

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kkhomeriki-nova-translatable/health.svg)

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

###  Alternatives

[spatie/nova-translatable

Making Nova fields translatable

2231.5M1](/packages/spatie-nova-translatable)[optimistdigital/nova-translatable

A laravel-translatable extension for Laravel Nova.

202427.4k5](/packages/optimistdigital-nova-translatable)[outl1ne/nova-translatable

A laravel-translatable extension for Laravel Nova.

203416.9k8](/packages/outl1ne-nova-translatable)[outl1ne/nova-translations-loader

This Laravel Nova package helps developers load translations into their packages.

395.1M42](/packages/outl1ne-nova-translations-loader)[optimistdigital/nova-translations-loader

This Laravel Nova package helps developers load translations into their packages.

393.7M10](/packages/optimistdigital-nova-translations-loader)[badinansoft/nova-language-switch

A Laravel Nova package to switch language in your application

26506.4k1](/packages/badinansoft-nova-language-switch)

PHPackages © 2026

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