victormgomes/auto-translate

Automatic translation for translatable attributes in Eloquent models

Maintainers

Package info

github.com/VictorMGomes/auto-translate

Homepage

Issues

pkg:composer/victormgomes/auto-translate

Fund package maintenance!

VictorMGomes

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 1

0.0.4 2026-04-28 07:52 UTC

This package is auto-updated.

Last update: 2026-04-28 08:01:39 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads License

Automatic translation for translatable attributes in Eloquent models

Introduction

Auto Translate is a powerful addon for spatie/laravel-translatable that automates the translation of your model attributes. It listens for model saving events and automatically translates your content into multiple languages using configured translation providers.

Why use this package?

  • Automation: Save time by letting the package handle translations automatically upon saving models.
  • Seamless Integration: Built specifically to work with the industry-standard spatie/laravel-translatable.
  • Declarative Configuration: Use PHP attributes to define which fields should be translated, keeping your models clean and readable.
  • Scalable: Easily manage multi-language content across your entire application without manual intervention.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by sponsoring us on GitHub.

Installation

You can install the package via composer:

composer require victormgomes/auto-translate

You can publish and run the migrations with:

php artisan vendor:publish --tag="auto-translate-migrations"
php artisan migrate

Usage

Simply use the AutoTranslatable trait and the #[AutoTranslate] attribute on your models. Specify which fields should be automatically translated.

use Victormgomes\AutoTranslate\Concerns\AutoTranslatable;
use Victormgomes\AutoTranslate\AutoTranslate;
use Spatie\Translatable\HasTranslations;

#[AutoTranslate(fields: ['name'])]
class Category extends Model
{
    use AutoTranslatable, HasTranslations;

    public $translatable = ['name'];
}

When you save the Category model, the name attribute will be automatically translated into all supported locales defined in your configuration.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.