PHPackages                             iperamuna/laravel-auto-translations - 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. iperamuna/laravel-auto-translations

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

iperamuna/laravel-auto-translations
===================================

Auto-generate JSON language files, AI translations, and a local-only language browser.

v0.0.1(10mo ago)11MITPHPPHP ^8.1

Since Jul 16Pushed 10mo agoCompare

[ Source](https://github.com/iperamuna/laravel-auto-translations)[ Packagist](https://packagist.org/packages/iperamuna/laravel-auto-translations)[ RSS](/packages/iperamuna-laravel-auto-translations/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Auto Translations
=========================

[](#laravel-auto-translations)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f16fc5939529cfccaa1b29281fe91cf275ac3be62f6c1942390d61ee171cb4d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69706572616d756e612f6c61726176656c2d6175746f2d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iperamuna/laravel-auto-translations)[![Total Downloads](https://camo.githubusercontent.com/28d2fe5852f3e1a46fdac65b20c635404e3fdcf146388593366b00605ed5c9ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69706572616d756e612f6c61726176656c2d6175746f2d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iperamuna/laravel-auto-translations)[![License](https://camo.githubusercontent.com/d1a226e42efbe30c5fc520e72dc65f944ceb55fa717a8ed2c0cba3bf8d937385/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f69706572616d756e612f6c61726176656c2d6175746f2d7472616e736c6174696f6e733f7374796c653d666c61742d737175617265)](LICENSE)

✨ Automatically scan your Laravel app for translation keys, export them to JSON, generate translations via OpenAI, and preview them in a simple local browser UI.

---

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

[](#-features)

- 🔍 Scan your entire Laravel app for `__('...')` usage
- 🧠 Generate translated JSON files via OpenAI (e.g., `en.json` → `es.json`)
- 🌐 Local-only language preview UI (`/langs`)
- 🔄 Export to nested i18n format (`lang:export-i18n`) for Vue or frontend use
- 🗃️ Offline caching of AI translations to avoid repeated costs
- ✅ Fully extendable, no frontend JS frameworks required

---

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

[](#-installation)

```
composer require iperamuna/laravel-auto-translations
php artisan vendor:publish --tag=auto-translations-config
```

Make sure you have `OPENAI_API_KEY` in your `.env`:

```
AUTO_TRANSLATE_REMOTE_VIEW_ENABLED=false
AUTO_TRANSLATE_REMOTE_VIEW_TOKEN=/*any*/
AUTO_TRANSLATE_OPENAI_API_BASE=https://api.groq.com/openai/v1
AUTO_TRANSLATE_OPENAI_MODEL=meta-llama/llama-4-scout-17b-16e-instruct
AUTO_TRANSLATE_OPENAI_API_KEY=gsk_..
```

---

🛠️ Artisan Commands
-------------------

[](#️-artisan-commands)

```
# 🔍 Scan your app and generate en.json
php artisan lang:generate-en-json

# 🌍 Create a new translation using AI
php artisan lang:new es --preview

# 🧱 Export to nested format (e.g., for Vue i18n)
php artisan lang:export-i18n en
```

---

🌐 Local Language Browser
------------------------

[](#-local-language-browser)

Access this route in `APP_ENV=local`:

```
http://localhost:8000/langs

```

> **Note:** This route is only registered in `local` environment.

- View translations from any existing `.json` language file
- Switch between languages with a dropdown
- Built using Tailwind CSS (via CDN)
- Can do remote view enabling AUTO\_TRANSLATE\_REMOTE\_VIEW\_ENABLED=true and setting up token by AUTO\_TRANSLATE\_REMOTE\_VIEW\_TOKEN

```
http://{remote.host.url}/langs?_token=***

```

---

📁 Output Examples
-----------------

[](#-output-examples)

### en.json (flat)

[](#enjson-flat)

```
{
  "auth.login": "Login",
  "profile.edit": "Edit Profile"
}
```

### en.i18n.json (nested)

[](#eni18njson-nested)

```
{
  "auth": {
    "login": "Login"
  },
  "profile": {
    "edit": "Edit Profile"
  }
}
```

---

📚 Configuration
---------------

[](#-configuration)

Publish the config:

```
php artisan vendor:publish --tag=auto-translations-config
```

You can configure:

```
