PHPackages                             abrarali/laravel-ai-polyglot - 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. abrarali/laravel-ai-polyglot

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

abrarali/laravel-ai-polyglot
============================

Laravel Polyglot: context-aware, AI-powered localization for Laravel 11+.

v0.1.0(5mo ago)01MITPHPPHP ^8.2

Since Dec 6Pushed 5mo agoCompare

[ Source](https://github.com/AbrarAli14/laravel-ai-polyglot)[ Packagist](https://packagist.org/packages/abrarali/laravel-ai-polyglot)[ Docs](http://portfolio.elzinabrar.com/)[ RSS](/packages/abrarali-laravel-ai-polyglot/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Polyglot
================

[](#laravel-polyglot)

Context-aware, AI-powered localization for Laravel. Turn your existing English UI into a truly multilingual product without drowning in thousands of translation keys.

Laravel Polyglot scans your Blade views for `__()` usages, feeds real code context to an AI translator, and writes clean PHP lang files for any locale supported by Laravel.

> For a full, step-by-step guide (with screenshots), install the package and open `/polyglot/docs` in your app.

---

Features
--------

[](#features)

- **Context-aware translations**

    - Scans your Blade views and passes HTML/code context to the AI driver.
    - Avoids classic mistakes like translating "save" as a noun when it should be a verb.
- **Works with any language**

    - Uses your fallback locale (usually `en`) as the source of truth.
    - Generates translations for any Laravel locale (`ar`, `he`, `it`, `my`, etc.).
- **Safe CLI workflow**

    - `polyglot:scan` to discover missing keys.
    - `polyglot:translate` with `--dry-run`, `--group`, `--route`, `--path`.
    - `polyglot:status` to measure coverage.
    - `polyglot:clean` with `--dry-run` to archive unused keys.
- **Review &amp; approval UI**

    - Built-in dashboard at `/polyglot/dashboard`.
    - Optional Filament v4 page for reviewing and approving pending translations.
    - Per-key metadata: `pending` vs `approved`, reused as translation memory.
- **Developer-first**

    - Plain PHP lang files under `lang/{locale}/{group}.php`.
    - No vendor lock-in; you can always edit files manually.
    - In-app docs at `/polyglot/docs` for your whole team.

---

Requirements
------------

[](#requirements)

- **PHP:** `^8.2`
- **Laravel:** 11.x (and future 12.x once released)
    - Package constraints: `illuminate/support` `^11.0|^12.0`, `illuminate/translation` `^11.0|^12.0`

---

Installation
------------

[](#installation)

Install via Composer in your Laravel application:

```
composer require abrarali/laravel-polyglot
```

Publish the config file (optional but recommended):

```
php artisan vendor:publish --provider="LaravelPolyglot\\PolyglotServiceProvider" --tag=config
```

This will create `config/polyglot.php` in your app.

---

Configuration
-------------

[](#configuration)

### 1. Driver &amp; OpenAI

[](#1-driver--openai)

Set your driver and API details in `.env`:

```
POLYGLOT_DRIVER=openai
POLYGLOT_OPENAI_API_KEY=your-key-here
POLYGLOT_OPENAI_MODEL=gpt-4.1-mini
# POLYGLOT_OPENAI_BASE_URL=https://api.openai.com/v1
```

You can also use the `dummy` driver for local development and testing.

### 2. Fallback locale

[](#2-fallback-locale)

Polyglot always translates **from** the fallback locale into your target languages.

```
// config/app.php
'fallback_locale' => 'en',
```

Make sure your English messages are defined, for example:

```
// lang/en/messages.php
return [
    'save' => 'Save',
    'login_now' => 'Login now',
    // ...
];
```

---

Quickstart
----------

[](#quickstart)

This is the shortest path from install to seeing Polyglot in action.

### 1. Add some `__()` calls

[](#1-add-some-__-calls)

In any Blade view (for example, your own page or the demo page), reference translation keys:

```
{{ __('messages.save') }}
{{ __('messages.login_now') }}
```

### 2. Scan for missing keys

[](#2-scan-for-missing-keys)

See which keys are missing in your fallback locale:

```
php artisan polyglot:scan --dry-run
```

Then let Polyglot create placeholders in `lang/en`:

```
php artisan polyglot:scan
```

### 3. Generate translations

[](#3-generate-translations)

Translate from `en` to a target locale, e.g. Spanish:

```
php artisan polyglot:translate es
```

Or limit to a specific group:

```
php artisan polyglot:translate de --group=messages
```

Or limit to a specific view path (keys that appear in that file):

```
php artisan polyglot:translate it \
  --group=messages \
  --path=resources/views/polyglot-demo-second.blade.php
```

> Tip: Add `--dry-run` to preview what would happen without calling the API or writing files.

### 4. Review &amp; approve

[](#4-review--approve)

Open the built-in dashboard:

- `/polyglot/dashboard`

There you can:

- See pending vs approved translations per locale.
- Edit text inline.
- Approve single keys or bulk-approve all pending items.

If you use Filament v4, you can also enable the **Polyglot Review** page in your admin panel.

### 5. Keep things clean

[](#5-keep-things-clean)

Check coverage for a locale:

```
php artisan polyglot:status es
```

Preview unused keys (safe mode):

```
php artisan polyglot:clean --dry-run
```

After checking the output, archive unused keys:

```
php artisan polyglot:clean
```

Unused keys are moved to `lang/archive/{locale}/{group}.php`, not deleted.

---

In-app documentation
--------------------

[](#in-app-documentation)

Laravel Polyglot ships with a modern, SaaS-style documentation page that lives **inside your app**.

By default, after installing the package and visiting your app in a browser:

- `https://your-app.test/polyglot/docs`
- `https://your-app.test/polyglot/documentation`In Localhost
- `http://127.0.0.1:8000/polyglot/docs`

You can change the route prefix and middleware in `config/polyglot.php` under the `ui` section.

The in-app docs include:

- A visual overview of the workflow.
- Copy-pasteable CLI commands.
- Tips for teams and CI.

---

Contributing
------------

[](#contributing)

Issues and pull requests are welcome.

- **Source &amp; issues:** [GitHub – AbrarAli14/laravel-polyglot](https://github.com/AbrarAli14/laravel-polyglot)

Please include reproduction steps and your Laravel/PHP versions when reporting bugs.

---

License
-------

[](#license)

Laravel Polyglot is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance72

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

158d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7af6a004da197108a0260873f7288e0bc57ac1da1ff913a3f4243f94dec6a0d2?d=identicon)[AbrarAliMussa](/maintainers/AbrarAliMussa)

---

Top Contributors

[![AbrarAli14](https://avatars.githubusercontent.com/u/70935986?v=4)](https://github.com/AbrarAli14 "AbrarAli14 (2 commits)")

---

Tags

laravellocalizationi18nl10ntranslationaiopenaipolyglot

### Embed Badge

![Health badge](/badges/abrarali-laravel-ai-polyglot/health.svg)

```
[![Health](https://phpackages.com/badges/abrarali-laravel-ai-polyglot/health.svg)](https://phpackages.com/packages/abrarali-laravel-ai-polyglot)
```

###  Alternatives

[kkomelin/laravel-translatable-string-exporter

Translatable String Exporter for Laravel

3291.4M10](/packages/kkomelin-laravel-translatable-string-exporter)[smousss/laravel-globalize

Make Laravel projects translatable in a matter of seconds!

2266.3k](/packages/smousss-laravel-globalize)

PHPackages © 2026

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