Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Nova Translatable

Nova Translatable Laravel Package

spatie/nova-translatable

Make any Laravel Nova field translatable with a simple Translatable wrapper. Works with spatie/laravel-translatable to store per-locale values in a JSON column, rendering locale tabs for editing. Requires Nova 4/5 and MySQL 5.7.8+.

View on GitHub
Deep Wiki
Context7

Making Nova fields translatable

Frequently asked questions about Nova Translatable
How do I make specific Nova fields translatable without altering my Eloquent models?
Wrap the fields in `Translatable::make()` within your Nova resource’s `fields()` method. For example, `Translatable::make([Text::make('title'), Trix::make('description')])` will make those fields translatable while leaving other fields unchanged. No model modifications are required unless you also use Spatie’s `laravel-translatable` package for model-level storage.
Does spatie/nova-translatable support Laravel Nova 3?
No, this package is designed for Nova 4 and 5 only. If you’re using Nova 3, you’ll need to check for alternative solutions or upgrade to a supported Nova version. Always verify compatibility with your Nova version before installation.
Can I use this package without installing spatie/laravel-translatable?
Yes, but with limitations. The package defaults to storing translations in a JSON column (via `laravel-translatable`), but you can manually handle translations in your models if you prefer. However, `laravel-translatable` provides helper methods and better performance for relational storage, so it’s recommended for most use cases.
How do I handle fallback locales if a translation is missing?
You can configure fallback locales in the `Translatable::make()` call or globally in your Nova resource. For example, `Translatable::make([...], 'en', ['fallback' => 'en'])` sets English as the default fallback. Alternatively, use `laravel-translatable`'s `setFallbackLocale()` method if you’re using relational storage.
Will this package work with Filament or Backpack for Laravel?
No, this package is specifically built for Laravel Nova and won’t integrate with Filament, Backpack, or other admin panels. If you’re using a different admin tool, you’ll need a package tailored to that ecosystem or a custom solution.
How do I test translatable fields in my Nova resource?
Test by creating assertions for locale-specific values in your Nova resource tests. For example, use `$resource->title->viaRequest()` to check translations in different locales. Mock the `Request` object to simulate locale changes and verify the correct translations are returned or saved.
Can I incrementally adopt this package for only some Nova resources?
Yes, you can start with a single resource (e.g., `Post`) by wrapping only the fields needing translation. This allows you to test the package’s behavior and performance before rolling it out to other resources. No full migration is required.
What are the performance implications of using JSON storage for translations?
JSON storage is simple and works out of the box, but it can impact query performance for large datasets or complex queries. For better performance, especially with high-traffic apps, consider using relational storage via `laravel-translatable`, which requires additional setup but offers scalability.
How do I add a locale selector dropdown in Nova for translatable fields?
You’ll need to create a custom Nova tool or toolbar to switch locales dynamically. Spatie provides examples in their documentation for adding UI elements to Nova. Alternatively, use a package like `spatie/nova-tool` to build a locale-switching tool that updates the translatable fields in real-time.
Are there alternatives to spatie/nova-translatable for Nova field translations?
Few packages offer this exact functionality, but you could build a custom solution using Nova’s field extensions or combine `laravel-translatable` with Nova’s `DetailField`/`IndexField` for manual handling. However, `spatie/nova-translatable` is the most maintained and feature-complete option for Nova-specific field translations.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport