- How do I migrate existing JSON/PHP translations to Lingua’s database without downtime?
- Use the `lingua:sync-to-database` artisan command to import existing files into the database. For zero-downtime migrations, run this in a staging environment first, then sync to production. The package handles nested arrays and dynamic keys, but test edge cases like custom translation logic (e.g., `trans_choice`) beforehand. Always back up your files before syncing.
- Does Lingua work with Laravel 13’s new features like Livewire 4.0 or Flux 2.0?
- Yes, Lingua is fully compatible with Laravel 13 and explicitly supports Livewire 4.0+ and Flux 2.0+. The UI leverages Flux components for a modern, reactive admin experience. No breaking changes are expected for Laravel’s latest features, as the package follows Laravel’s backward-compatibility promises for these versions.
- Can I use Lingua in a multi-environment setup (dev/staging/prod) with different translation sync strategies?
- Absolutely. Lingua supports environment-specific sync strategies via artisan commands. For example, sync from files to the database in staging (`lingua:sync-to-database`), then pull changes back to files in production (`lingua:sync-to-files`) during deployments. Use `.env` variables to configure drivers per environment (e.g., `LINGUA_DEFAULT_DRIVER=database` in prod, `file` in dev).
- How does performance compare between database and file-based translation lookups?
- Database lookups are optimized with Eloquent’s query builder and caching. For large translation sets, Lingua includes query optimizations like indexing and lazy-loading. File-based lookups (when using the `file` driver) are faster for read-heavy apps but lack real-time edit capabilities. Benchmark your use case: database is ideal for collaborative editing, while files suit static or read-only translations.
- Is the AI translation feature open-source, or does it require a paid API?
- The AI translation feature integrates with third-party APIs (e.g., DeepL, Google Translate) but is not bundled with Lingua. You’ll need to configure API keys via `.env` (e.g., `LINGUA_AI_PROVIDER=deepl`). Costs depend on the provider’s pricing model. The package handles rate limits and error states gracefully, but you’re responsible for managing API credentials securely.
- Can I customize the Livewire UI to match my Tailwind theme or add JavaScript hooks?
- Yes, Lingua’s UI is fully customizable via Blade/Livewire overrides. Publish the views with `php artisan vendor:publish --tag=lingua-views` and modify the published files in `resources/views/vendor/lingua`. For Tailwind, override the CSS variables in `resources/css/lingua.css`. JavaScript hooks can be added via Livewire’s `wire:init` or Alpine.js directives in the published Blade files.
- What happens if the database sync fails mid-operation? Are there fallbacks for partial data loss?
- Lingua includes transaction support for database operations to prevent partial updates. If a sync fails, the package logs detailed errors and rolls back changes. For critical backups, manually export translations via `lingua:export` before syncing. Test syncs in a staging environment first to validate your data integrity. The `file` driver acts as a fallback if database issues arise.
- Does Lingua support role-based access control (RBAC) for the admin UI?
- Lingua does not include built-in RBAC, but you can integrate it with Laravel’s native authorization (e.g., Gates, Policies) or packages like Spatie’s Laravel-Permission. Restrict access to `/lingua` routes using middleware like `can:manage-translations`. The UI is designed to work with Laravel’s auth system, so you can gate features like edit/delete permissions at the route or component level.
- How do I handle rich-text translations (HTML/Markdown) securely to avoid XSS?
- Lingua sanitizes rich-text translations by default, but you may need additional validation for complex cases. Use packages like `spatie/laravel-html` to sanitize output before rendering. Configure allowed HTML tags in `config/lingua.php` under `sanitize_html`. For Markdown, consider converting to HTML with a package like `commonmark/commonmark` and then sanitizing the result.
- Are there alternatives to Lingua for Laravel translation management, and how does it compare?
- Alternatives include `spatie/laravel-translation-manager` (file-based, simpler UI) and `laravel-lang` (external service integration). Lingua stands out with its database-driven approach, real-time Livewire UI, and bidirectional sync. Unlike file-based tools, it enables collaborative editing without redeploys. For AI features, Lingua offers more flexibility than hosted services, while `laravel-lang` may suit teams preferring external APIs without self-hosting.