PHPackages                             tonydev/lara-glot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. tonydev/lara-glot

ActiveLibrary

tonydev/lara-glot
=================

Smart Auto-Translation for Laravel Models with JSON/HTML support

v1.0.0(1mo ago)02↑2900%MITPHPPHP ^8.2

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/t27124949-cell/lara-glot)[ Packagist](https://packagist.org/packages/tonydev/lara-glot)[ RSS](/packages/tonydev-lara-glot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

This is the updated, full **README.md**. I've integrated the new **Filament Actions**, the **CLI Progress Bar** details, and the **Logging/Troubleshooting** section to make it a complete professional guide.

---

LaraGlot 🌍
==========

[](#laraglot-)

**Smart Auto-Translation for Laravel Models**

LaraGlot is a professional-grade Laravel package designed to handle automated, background translations for Eloquent models. It supports complex JSON structures (like Filament Page Builders), HTML content chunking, and SEO auto-population using the Google Translate API.

---

🚀 Features
----------

[](#-features)

- **Automatic Translation:** Hooks into Eloquent `saved` events seamlessly.
- **Smart JSON Handling:** Recursively translates nested arrays while skipping non-translatable keys (URLs, IDs, Slugs).
- **HTML Chunking:** Automatically splits large text blocks (over 2000 chars) to avoid API limits and timeouts.
- **SEO Auto-Pilot:** Automatically populates `meta_title` and `meta_description` from your main content if they are empty.
- **Filament Ready:** Includes ready-to-use Actions and Bulk Actions for your Filament resources.
- **CLI Progress Bar:** Real-time feedback during bulk database synchronization.
- **Queue Ready:** Dispatches jobs to background workers with built-in exponential backoff for API reliability.

---

📦 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require tonydev/lara-glot
```

Publish the configuration file:

```
php artisan vendor:publish --tag=lara-glot-config
```

---

⚙️ Configuration
----------------

[](#️-configuration)

In `config/lara-glot.php`, define your source language, target languages, and supported models.

```
return [
    'source_locale' => 'en',
    'languages' => [
        'es' => 'Spanish',
        'fr' => 'French',
        'ar' => 'Arabic',
        // Add more as needed...
    ],
    'queue' => 'translations',
    'models' => [
        \App\Models\Post::class,
    ],
];
```

---

🛠 Usage
-------

[](#-usage)

### 1. Prepare your Model

[](#1-prepare-your-model)

Your model should use the `HasSmartTranslations` trait. It works perfectly alongside `spatie/laravel-translatable`.

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tonydev\LaraGlot\Traits\HasSmartTranslations;
use Spatie\Translatable\HasTranslations;

class Post extends Model
{
    use HasTranslations, HasSmartTranslations;

    public $translatable = ['title', 'body', 'meta_title', 'meta_description'];

    public function getTranslatableAttributes(): array
    {
        return $this->translatable;
    }
}
```

### 2. Bulk Syncing (CLI)

[](#2-bulk-syncing-cli)

To translate existing records or force an update across your database with a visual progress bar:

```
# Sync all models defined in config
php artisan laraglot:sync

# Force re-translation of a specific model
php artisan laraglot:sync "App\Models\Post" --force
```

### 3. Filament Integration

[](#3-filament-integration)

Add manual translation triggers to your Filament Resource tables:

```
use Filament\Tables;
use Filament\Notifications\Notification;
use Tonydev\LaraGlot\Jobs\TranslateModelJob;

// Inside Table Actions
Tables\Actions\Action::make('translate')
    ->label('Translate Now')
    ->icon('heroicon-o-language')
    ->requiresConfirmation()
    ->action(function ($record) {
        TranslateModelJob::dispatch(get_class($record), $record->getKey(), true)
            ->onQueue(config('lara-glot.queue'));

        Notification::make()->title('Translation Started')->success()->send();
    }),

// Inside Bulk Actions
Tables\Actions\BulkAction::make('translate_selected')
    ->label('Translate Selected')
    ->icon('heroicon-o-language')
    ->action(function (\Illuminate\Support\Collection $records) {
        $records->each(fn($record) => TranslateModelJob::dispatch(get_class($record), $record->getKey(), true));
        Notification::make()->title('Bulk Translation Started')->success()->send();
    })
```

---

🏗 Architecture
--------------

[](#-architecture)

- **TranslationService:** Wrapper for the Google Translate API with multi-layer caching.
- **SmartTranslationService:** The logic engine for recursive array and HTML processing.
- **TranslateModelJob:** Queueable worker with a 10-minute timeout and 3-step incremental backoff.
- **HasSmartTranslations:** The trait that connects your models to the engine.

---

📋 Troubleshooting &amp; Logs
----------------------------

[](#-troubleshooting--logs)

Monitor progress in `storage/logs/laravel.log`:

- `🚀 [LaraGlot] Translation Job Started` — Job picked up by worker.
- `🌍 [LaraGlot] Translating [es]: ...` — Specific string being sent to API.
- `✅ [LaraGlot] Translation completed` — Success!
- `❌ [LaraGlot] Translation Job Failed` — Errors (API limits, network) are logged here before retrying.

---

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

**Developed by Tonydev**

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/266398964?v=4)[t27124949-cell](/maintainers/t27124949-cell)[@t27124949-cell](https://github.com/t27124949-cell)

---

Top Contributors

[![yumyum154](https://avatars.githubusercontent.com/u/147006386?v=4)](https://github.com/yumyum154 "yumyum154 (1 commits)")

### Embed Badge

![Health badge](/badges/tonydev-lara-glot/health.svg)

```
[![Health](https://phpackages.com/badges/tonydev-lara-glot/health.svg)](https://phpackages.com/packages/tonydev-lara-glot)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

198277.9k](/packages/fumeapp-modeltyper)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
