- How do I install dskripchenko/laravel-translatable in a Laravel app?
- Install it with Composer using composer require dskripchenko/laravel-translatable. After installation, add the provided translatable trait to the Eloquent models that need multilingual attributes. Check the repository README for any version-specific setup or configuration publishing steps.
- How does laravel-translatable store translations for Eloquent models?
- It stores multilingual values alongside your Eloquent models, so each translatable attribute can hold a value per locale. You interact with those attributes through the model rather than through separate translation models. The package is designed as a lightweight, trait-based approach for multilingual Laravel applications.
- Can I switch the application locale at runtime with this package?
- Yes, the package supports switching locales at runtime. You can change the active locale and read the same translatable attribute in the selected language. This is useful for APIs, per-user language preferences, or admin previews of multilingual content.
- What happens when a translation is missing for the current locale?
- The package falls back gracefully when a translation is missing. Instead of returning an empty value, it can use fallback behavior so your application still displays a usable string. Review the package documentation for details on configuring fallback locales.
- Is dskripchenko/laravel-translatable compatible with my Laravel version?
- The package is built for Laravel applications and uses a trait-based Eloquent approach. Exact Laravel version constraints should be checked in the repository composer.json and README. Verify compatibility before upgrading major Laravel versions.
- Do I need separate translation tables for each translatable model?
- The package is described as storing multilingual attributes alongside your Eloquent models. That means translations stay close to the model data instead of requiring a separate translation model for every translatable entity. Review the schema and trait usage in the README to confirm the exact database design.
- How do I make an existing Eloquent model translatable?
- Add the package's translatable trait to the model class. Then define which attributes should be treated as multilingual according to the package documentation. Once configured, you can read and write those attributes per locale using the package's runtime locale handling.
- Can I use laravel-translatable for multilingual APIs?
- Yes, runtime locale switching and graceful fallbacks make it suitable for APIs that return content in the requested language. You can set the locale based on a request header, user preference, or route parameter before serializing the model. Make sure your API responses use the active locale consistently.
- How does this package compare to other Laravel translation packages?
- It is a lightweight, trait-based option for adding translatable attributes directly to Eloquent models. It focuses on storing multilingual values alongside models, runtime locale switching, and fallback behavior rather than a heavy separate translation system. Compare its schema and API with your project's needs, especially if you require translation management workflows.
- Is dskripchenko/laravel-translatable actively maintained and safe for production?
- Maintenance status should be verified on the GitHub repository by checking recent commits, releases, and open issues. For production use, test the package against your Laravel version and database, and confirm fallback behavior for missing translations. Its trait-based approach keeps integration focused on the models that need multilingual attributes.