PHPackages                             warmar/laravel-ai-translate - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. warmar/laravel-ai-translate

ActiveLibrary[Localization &amp; i18n](/categories/localization)

warmar/laravel-ai-translate
===========================

Complete multilingual framework for Laravel with AI translation, automatic routing, SEO optimization, and RTL support

v2.1.3(1mo ago)023MITPHPPHP ^8.2|^8.3|^8.4

Since Jan 26Pushed 1mo agoCompare

[ Source](https://github.com/warmar94/laravel-ai-translate)[ Packagist](https://packagist.org/packages/warmar/laravel-ai-translate)[ Docs](https://warmardev.com)[ RSS](/packages/warmar-laravel-ai-translate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (32)Used By (0)

Laravel AI Translation System
=============================

[](#laravel-ai-translation-system)

**Docs:**

A **complete multilingual framework** for Laravel applications. This isn't just a translation tool - it's a full-featured localization system with AI-powered translations, automatic routing, SEO optimization, and RTL support out of the box.

**Built on top of Laravel's default translation system** — no custom Blade directives or proprietary syntax. Uses standard `__()` everywhere, so your templates stay clean and portable.

**What it adds on top of Laravel's built-in translation:**

- ✅ Automatic language-prefixed routing (`/about`, `/ar/about`)
- ✅ Smart language detection middleware
- ✅ AI-powered translation with OpenAI
- ✅ **Dual string collection** — active URL scanning + passive runtime detection via Laravel's `handleMissingKeysUsing`, with configurable `runtime_collection` toggle
- ✅ Real-time translation dashboard with live progress tracking
- ✅ **Missing Keys dashboard** — auto-detected untranslated strings from live traffic with per-locale tracking
- ✅ Complete SEO implementation (hreflang, canonical URLs)
- ✅ RTL language support
- ✅ Global helper functions for easy integration
- ✅ Database-backed URL management with API endpoint auto-fetching
- ✅ Eloquent models for all database operations
- ✅ Inline manual translation editor per language
- ✅ Per-string AI translation (individual or batch)

🌟 Features
----------

[](#-features)

### 🎯 Core Translation Features

[](#-core-translation-features)

- 🤖 **AI-Powered Translations**: Leverages OpenAI GPT-4 for high-quality translations
- 🔍 **Dual String Collection**: Active URL scanning + passive detection via Laravel's native `handleMissingKeysUsing` hook — new strings are caught automatically from live traffic. A configurable `runtime_collection` flag controls whether passive collection runs on every request or only during active scans, giving you full control over production overhead
- 🌐 **Multi-Language Support**: Translate your entire application into unlimited languages
- 📊 **Real-Time Dashboard**: Beautiful Livewire-powered interface with live progress tracking
- ⚡ **Queue-Based Processing**: Scalable batch processing for thousands of strings
- 🎯 **Zero Custom Syntax**: Uses Laravel's standard `__()` function — no proprietary directives, no learning curve, templates stay clean and portable
- 🗃️ **Missing Keys Tracking**: Database-backed `translation_missing` table with occurrence counts, first/last seen timestamps, grouped by locale — automatically populated from live traffic
- 🔧 **Local API Deadlock Prevention**: Internal request handling for local API endpoints avoids single-threaded `php artisan serve` deadlock

### 🔗 URL Management

[](#-url-management)

- 🗄️ **Database-Backed URLs**: All URLs stored in a dedicated `translation_urls` table with full CRUD support
- 🌐 **API Endpoint Auto-Fetching**: Add API endpoints that return JSON arrays of URLs — the system fetches and imports them automatically
- 🔄 **Re-Fetchable Endpoints**: Saved API endpoints can be re-triggered at any time to discover new URLs
- 🔍 **Search &amp; Filter**: Search URLs inline, toggle active/inactive, bulk add or clear
- 📊 **Indexed for Scale**: Database columns indexed for performance with tens of thousands of URLs

### 🚀 Advanced Routing &amp; Localization

[](#-advanced-routing--localization)

- 🛣️ **Smart Language Routing**: Automatic language-prefixed URLs (`/about`, `/ar/about`, `/es/about`)
- 🔧 **Custom `langRoute()` Helper**: One function to create all language routes automatically
- 🌍 **Language Middleware**: Intelligent language detection and switching
- 📝 **SEO-Optimized**: Auto-generated hreflang tags, canonical URLs, and x-default handling
- 🔄 **Language Switcher**: Built-in helpers for creating language selection menus
- ↔️ **RTL Support**: Full right-to-left language support with automatic detection
- 🎨 **Global Helper Functions**: `langUrl()`, `isRtl()`, `isRoute()`, and `langCode()` available everywhere

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Database Schema](#database-schema)
- [File Structure](#file-structure)
- [Configuration](#configuration)
- [Routing System](#routing-system)
- [Language Middleware](#language-middleware)
- [Usage](#usage)
- [View Helpers](#view-helpers)
- [How It Works](#how-it-works)
- [Advanced Features](#advanced-features)
- [Troubleshooting](#troubleshooting)
- [API Reference](#api-reference)

⚙️ Requirements
---------------

[](#️-requirements)

- PHP 8.2+
- Laravel 11+ / 12+
- OpenAI API Key
- Queue worker (Redis recommended, Database queue supported)
- Livewire 3.x / 4.x

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

[](#-installation)

### 1. Publish Laravel's Default Localization

[](#1-publish-laravels-default-localization)

```
php artisan lang:publish
```

### 2. Install the package via Composer

[](#2-install-the-package-via-composer)

```
composer require warmar/laravel-ai-translate
```

### 3. Install the package assets

[](#3-install-the-package-assets)

```
php artisan ai-translate:install
```

### 4. Register the Service Provider

[](#4-register-the-service-provider)

Add the `TranslationServiceProvider` to your `bootstrap/providers.php`:

```
