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
Laravel Translatable

Laravel Translatable Laravel Package

novius/laravel-translatable

Make Laravel Eloquent models translatable using locale and locale_parent_id fields. Provides migration macro, Translatable trait with translations relations (incl. soft-deleted), translate/getTranslation helpers, and withLocale query scope. Supports Laravel 10–13, PHP 8.2–8.5.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Laravel Translatable
How do I add translatable fields to an Eloquent model in Laravel?
Use the `translatable()` migration macro in your schema definition to add `locale` and `locale_parent_id` fields, then apply the `Translatable` trait to your model. The package handles the rest, including translation relations and query scopes.
Does `novius/laravel-translatable` support Laravel 13?
Yes, the package officially supports Laravel 10 through 13. Check the [GitHub repository](https://github.com/novius/laravel-translatable) for the latest version compatibility before installing.
Can I customize which attributes are translatable in my model?
Yes, override the `translatableConfig()` method in your model to specify custom attributes for translation. By default, all non-reserved fields are translatable unless excluded.
How do I handle missing translations (fallbacks) in my app?
The package doesn’t enforce fallbacks, so you’ll need to implement logic manually—e.g., fetch translations from a default locale or return `null`. Use `getTranslation()` with a fallback check in your application code.
Will soft-deleted parent models automatically delete their translations?
No, soft deletes on parent models won’t cascade to translations by default. Use the `translationsWithDeleted` relation to include soft-deleted translations, or configure cascading deletes in your migration.
Is this package suitable for high-traffic applications with many languages?
The package uses a single-table design, which may struggle with >50 languages or millions of records. Monitor performance and consider indexing `locale` and `locale_parent_id` fields. For scalability, alternatives like `spatie/laravel-translatable` might be better.
How do I query translations for a specific locale in Laravel?
Use the `withLocale($locale)` scope on your model’s query builder. For example, `Post::withLocale('en')->get()` retrieves only English translations. Combine with `getTranslation()` for single-record lookups.
Does this package support many-to-many translation relationships (e.g., multilingual tags)?
No, this package is designed for one-to-many relationships (parent → translations). For many-to-many scenarios (e.g., tags), consider a custom solution or packages like `spatie/laravel-translatable` with pivot tables.
How do I test translations in my Laravel application?
Mock translations in unit tests by creating model instances with `translate()` or manually setting `locale` and `locale_parent_id`. Use `getTranslation()` to verify locale-specific data. For integration tests, seed translations in your database.
What are the license implications of using `novius/laravel-translatable` in a proprietary project?
The package is licensed under AGPL-3.0, which may require open-sourcing your project or forking the package. Review the license carefully or consider alternatives like `spatie/laravel-translatable` (MIT) for proprietary use.
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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony