- How do I install Nova Translations Loader in my Laravel Nova project?
- Run `composer require outl1ne/nova-translations-loader` in your project directory. The package requires PHP 8.0+, Laravel 9/10, and Nova 4.0+ for full compatibility. After installation, publish the config if needed using the package’s service provider.
- Which Laravel Nova versions does this package support?
- The package officially supports Nova 4.0+. While it may work with Nova 3.x, test thoroughly as some features (like translation publishing) rely on newer Nova APIs. Check the GitHub repo for version-specific notes if targeting older Nova releases.
- Can I use custom translation file paths with this loader?
- Yes, you can specify custom paths via the `NovaTranslationsLoader::paths()` method or by configuring the `loadTranslations()` call in your service provider. Defaults to `resources/lang/` if no path is provided, but you can override it for vendor-specific or nested translation directories.
- Will this package conflict with other Nova packages using translations?
- Conflicts are unlikely if other packages use standard Laravel translation loading. However, if multiple packages override translation logic (e.g., via service providers), prioritize loading order or use unique namespace prefixes for keys to avoid clashes.
- How does the loader handle missing translation keys?
- The package follows Laravel’s default behavior: missing keys fall back to the parent locale or return the key itself if no fallback exists. You can customize this by extending the loader’s fallback logic or using Laravel’s `trans()` helper with a default value.
- Does Nova Translations Loader support RTL languages or pluralization rules?
- Yes, the package leverages Laravel’s built-in localization system, which natively supports RTL languages and pluralization rules (e.g., `resources/lang/ar/plurals.php`). Test your specific RTL locales to ensure UI rendering aligns with expectations.
- How do I load translations for a specific Nova package?
- Use the `LoadsNovaTranslations` trait in your package’s service provider and call `$this->loadTranslations(__DIR__ . '/../resources/lang', 'your-package-name', true)`. The third parameter enables publishable translations, useful for admin-editable strings.
- What’s the performance impact of loading translations dynamically?
- The overhead is minimal for most use cases. Dynamic loading adds a slight delay during package initialization, but caching (via Laravel’s translation system) mitigates repeated loads. For 100+ packages, benchmark in staging to ensure no bottlenecks in Nova’s admin panel.
- Can I use this package in non-Nova Laravel projects?
- No, this package is designed exclusively for Laravel Nova. For standard Laravel apps, use Laravel’s built-in `trans()` helper or packages like `spatie/laravel-translation-loader` for similar functionality without Nova dependencies.
- How do I test translations before deploying to production?
- Publish the translations via Nova’s admin panel (if enabled) and verify strings render correctly across locales. Use Laravel’s `trans()` helper in Blade or PHP to test fallback behavior. For automated testing, mock the translation loader in unit tests with `partialMock()`.