rslanzi/nova-translatable
A Laravel Nova package for translatable fields. Manage multilingual content directly in your Nova resources with per-locale inputs, integrating with spatie/laravel-translatable so you can edit translations alongside your models.
composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\\<Package>\\ServiceProvider"
php artisan migrate
config/app.php locale and any existing multilingual columns.use Vendor\Package\Traits\HasTranslations;
class Article extends Model
{
use HasTranslations;
public $translatable = ['title', 'body'];
}
title for the main locale.title to '' or null for the main locale and save again.Accept-Language, a route parameter, or a session value.
app()->setLocale($request->get('locale', config('app.locale')));
$article->title = $request->input('title');
$article->save();
foreach ($request->input('translations', []) as $locale => $fields) {
$article->setTranslations($locale, $fields);
}
$article->save();
return [
'title' => $article->title,
'translations' => $article->translations,
];
'' versus null. The fix covers empty fields, but your validation and normalization rules should be consistent so an editor clearing a field does not accidentally trigger a fallback.save().''.null.save(), the package’s translation table rows after save, and whether the model was recently changed. The patch specifically targets the main language, so verify the active locale at write time.How can I help you explore Laravel packages today?