- 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.