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

Translatable For Laravel Laravel Package

roundly-consulting/translatable-for-laravel

A Laravel package that brings locale-aware translations to Eloquent models, letting you store and retrieve attribute values per language with fallback support. It simplifies building multilingual applications while staying close to Laravel conventions and reducing boilerplate.

View on GitHub
Deep Wiki
Context7

Locale-map (jsonb) translatable attributes with a fallback chain for Eloquent; per-locale slugs via sluggable-for-laravel — native, zero third-party deps.

Frequently asked questions about Translatable For Laravel
How do I install roundly-consulting/translatable-for-laravel?
Install it with Composer using composer require roundly-consulting/translatable-for-laravel. Laravel package discovery should register the package service provider automatically in standard applications. If your app uses dont-discover or manually registers providers, add the provider yourself and verify the migration macro is available. Then run your migrations and confirm the translatable() macro is recognized.
Which Laravel and PHP versions does translatable-for-laravel support?
The release notes for 1.1.2 do not publish a complete compatibility matrix, so check the package composer.json for the exact Laravel, PHP, Larastan, and PHPStan constraints. Validate against your app's versions before upgrading. Apps using Testbench, dont-discover, or manual provider registration should test static analysis specifically.
How does translatable-for-laravel store translations in the database?
It uses a locale-map jsonb approach, so each translatable attribute stores a map of locale codes to values rather than one column per language or a separate translations table. You define the attribute with the $table->translatable('name') migration macro. This keeps localized content close to the model while remaining queryable as JSON. Review your database's jsonb or JSON support before adopting it.
How do I make an Eloquent attribute translatable?
Add the attribute in a migration using the package's $table->translatable('name') macro, then read and write localized values through the model's translatable behavior. Check the package README for the exact model API and any trait names. The package is designed to stay close to standard Laravel conventions and reduce boilerplate for localized attributes.
How does the fallback chain work when a translation is missing?
When you request a translatable attribute, the package resolves the current locale first and then walks a configured fallback chain until it finds a value. That lets you show a default-language value instead of an empty string when a translation is incomplete. Configure the fallback order to match your application's locale strategy.
Can I generate per-locale slugs for translatable models?
Yes, the package is designed to work with sluggable-for-laravel for per-locale slugs. You configure slug generation against the localized source attribute for each locale. Check the companion package documentation for the exact slug column and locale mapping, because those details are not fully covered in the release notes.
Does translatable-for-laravel work with Larastan and PHPStan?
Yes, it ships a PHPStan extension so static analysis understands the translatable() migration macro. With phpstan/extension-installer installed, the extension loads automatically through extra.phpstan.includes. Release 1.1.2 fixes a false positive when the service provider is not booted during PHPStan, such as in Testbench or dont-discover setups. Run PHPStan or Larastan in CI after upgrading to confirm.
Why does PHPStan report a call to an undefined method translatable()?
PHPStan does not know about the migration macro unless the package's PHPStan extension is loaded. Install phpstan/extension-installer or explicitly include vendor/roundly-consulting/translatable-for-laravel/extension.neon in your PHPStan configuration. If you are on an older release, upgrade to 1.1.2, which addresses a false positive when the provider is not booted. Clear config caches and rerun static analysis.
Is upgrading to 1.1.2 a breaking change for production?
No breaking changes or deprecations are indicated for 1.1.2; it is a developer-tooling compatibility patch for static analysis. Runtime behavior should be largely unchanged, but you should still validate the migration macro and translatable data model in staging. Roll out to CI and development first, then production.
How should I test translatable models in CI?
Run your normal Laravel test suite plus migration tests that exercise the translatable() macro. Add PHPStan or Larastan to CI so the extension is verified, especially if you use dont-discover, Testbench, or manual provider registration. Include tests for locale fallback behavior and per-locale slugs if you use sluggable-for-laravel. Keep the package, Larastan, and PHPStan versions reasonably aligned.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo