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 Package

spatie/laravel-translatable

Adds a HasTranslations trait to Eloquent models to store translations as JSON in the same table (no extra tables). Define translatable attributes via PHP attribute or $translatable, then set/get translations per locale and auto-resolve by app locale.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Multilingual Content Strategy: Enables seamless support for multilingual applications without requiring complex database schemas (e.g., no need for separate tables or join tables for translations). Ideal for global products, localized SaaS platforms, or content-heavy applications (e.g., CMS, e-commerce, or knowledge bases).
  • Roadmap for Localization Features:
    • Phase 1: Basic multilingual support for product names, descriptions, or user-generated content (e.g., blog posts, reviews).
    • Phase 2: Advanced use cases like nested JSON translations (e.g., localized metadata, dynamic content blocks) or integration with third-party translation APIs (e.g., DeepL, Google Translate).
    • Phase 3: Scalability optimizations (e.g., caching strategies for translations, bulk translation updates).
  • Build vs. Buy Decision:
    • Buy: Avoids reinventing the wheel for a common problem. Spatie’s package is battle-tested, well-documented, and actively maintained (MIT license, 2.4K stars, recent Laravel 13 support).
    • Build: Only consider if you need highly customized translation logic (e.g., real-time translation sync with external systems) or non-JSON storage (e.g., Redis for caching).
  • Use Cases:
    • Content Management: Localize blog posts, articles, or marketing pages.
    • E-Commerce: Translate product names, descriptions, and categories.
    • User-Generated Content: Allow users to submit content in multiple languages (e.g., reviews, forum posts).
    • Admin Panels: Provide translators or editors with tools to manage translations via a dashboard.
    • APIs: Serve localized responses dynamically based on client locale headers.

When to Consider This Package

  • Adopt This Package If:

    • Your application requires multilingual support but you want to avoid complex database migrations (e.g., no separate tables for translations).
    • You’re using Laravel and want a lightweight, well-maintained solution with JSON-based storage for translations.
    • Your team prefers PHP attributes (Laravel 8+) or traditional $translatable arrays for defining translatable fields.
    • You need query scopes to filter records by translation locale or content (e.g., whereLocale, whereJsonContainsLocale).
    • Your use case involves nested translations (e.g., JSON fields like meta->description).
    • You want to minimize overhead (no additional tables, simple API for setting/getting translations).
  • Look Elsewhere If:

    • You need real-time translation (e.g., auto-translation via API calls during save). This package stores translations statically in JSON.
    • Your application requires fine-grained access control for translations (e.g., per-locale permissions). The package doesn’t natively support this; you’d need to layer additional logic.
    • You’re using a non-Laravel PHP framework or need a non-JSON storage solution (e.g., Redis, Elasticsearch).
    • Your team lacks PHP/Laravel expertise to implement or debug the package. While well-documented, it requires understanding of Eloquent and JSON handling.
    • You need translation memory or terminology management (e.g., tracking repeated phrases). This package focuses on storage, not translation workflows.
    • Your database schema is highly normalized and you prefer relational integrity over JSON flexibility.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us launch a multilingual version of [Product] with minimal engineering effort. Instead of building a custom translation system—which would require months of development and maintenance—we can leverage spatie/laravel-translatable to store translations in a single JSON column per model. This reduces database complexity, speeds up development, and cuts costs. For example, we could localize our blog, product descriptions, or help center content without adding new tables or joins. The package is used by thousands of developers, is actively maintained, and integrates seamlessly with Laravel—our existing tech stack. It’s a low-risk, high-reward decision that aligns with our goal to expand into [target markets]."

Key Outcomes:

  • Faster time-to-market for localization features.
  • Reduced backend complexity (no additional tables).
  • Scalable for future needs (e.g., adding more languages or nested translations).

For Engineering Teams:

*"spatie/laravel-translatable is a lightweight, battle-tested solution for adding multilingual support to Eloquent models. Here’s why it’s a great fit for us:

  1. Simplicity: Translations are stored as JSON in a single column—no need for join tables or complex migrations. Just add the HasTranslations trait to your model and define translatable fields via attributes or a $translatable array.

    • Example:
      #[Translatable('title', 'description')]
      class BlogPost extends Model { use HasTranslations; }
      
  2. Flexibility:

    • Supports nested JSON translations (e.g., meta->keywords).
    • Works with Laravel’s query builder (e.g., whereLocale, whereJsonContainsLocale for filtering).
    • Handles null values and empty strings configurably.
  3. Performance:

    • No additional database queries for translations (everything is in one JSON column).
    • Minimal overhead for read/write operations.
  4. Maintenance:

    • Actively maintained (last release: April 2026, Laravel 13 support).
    • MIT license, no vendor lock-in.
    • Well-documented with clear examples.

Trade-offs:

  • Translations are stored statically (no real-time API integration).
  • Querying translations requires JSON functions (e.g., whereJsonContainsLocale), which may impact performance for large datasets.

Recommendation: Use this for content-heavy localization (e.g., blogs, products, CMS). If we need real-time translation or advanced workflows later, we can layer in additional services (e.g., a translation API or a dedicated translations table)."*

Next Steps:

  • Demo the package with a proof-of-concept (e.g., localize a Product model).
  • Discuss integration with our existing i18n setup (e.g., how locale detection works).
  • Plan for future scalability (e.g., caching strategies, bulk updates).
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai