eii/laravel-ai-locale-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eii/laravel-ai-locale-generator

Composer 安装命令:

composer require eii/laravel-ai-locale-generator

包简介

AI powered localization generator for Laravel

README 文档

README

AI-powered localization generator for Laravel applications.
Automatically extracts texts from Blade files, generates locale keys, optionally translates to multiple languages, and safely updates your Blade files.

Features

  • Extract texts from Blade files and generate locale keys
  • AI-assisted key generation (OpenAI)
  • Translation support (Google Translate & DeepL)
  • Multi-language locale PHP files (resources/lang/en/*.php, ja, es, etc.)
  • Safe Blade rewriting with optional backup
  • Dot notation support (welcome, auth.login) for Blade files
  • Fully configurable via config/ai-locale-generator.php
  • CLI commands for automated workflows

Installation

composer require eii/laravel-ai-locale-generator

Publish the config file:

php artisan vendor:publish --tag=ai-locale-generator-config

Update your .env with API keys:

OPENAI_API_KEY=sk-xxx
GOOGLE_TRANSLATE_API_KEY=xxx
DEEPL_API_KEY=xxx

Configuration

config/ai-locale-generator.php:

return [
    'provider' => 'openai',
    'api_key' => env('OPENAI_API_KEY'),
    'model' => 'gpt-4o-mini',

    'translator' => 'google', // options: 'google', 'deepl'
    'google_api_key' => env('GOOGLE_TRANSLATE_API_KEY'),
    'deepl_api_key' => env('DEEPL_API_KEY'),
    
    'backup' => true, // default: backup Blade files before applying
];

Commands

1. Generate Locale Files

php artisan locale:generate <blade_file> [--lang=ja,es]
  • Extracts texts from the Blade file
  • Creates source language file resources/lang/en/<blade>.php automatically
  • Translates to languages specified in --lang (optional)
  • Example:
php artisan locale:generate welcome --lang=ja,es

2. Apply Keys to Blade

php artisan locale:apply <blade_file> [--backup|--no-backup]
  • Replaces original texts with locale keys
  • Uses APP_LOCALE as source language
  • Optional backup (.bak) before rewriting
  • Example:
php artisan locale:apply welcome auth.login --backup

Usage Notes

  • Source language is always your APP_LOCALE (.env).
  • Translation languages are optional.
  • Currently does not handle dynamic variables in texts (e.g., :count). Planned for future release.
  • Supports both single and double-quoted Blade translations.

Example Workflow

  1. Generate keys & translations:
php artisan locale:generate welcome --lang=ja,es
  1. Manually edit translations if needed:
// resources/lang/ja/welcome.php
'welcome_message' => 'ようこそ',
  1. Apply keys to Blade:
php artisan locale:apply welcome
  1. Now your Blade file uses:
{{ __('welcome.welcome_message') }}

Requirements

  • PHP 8.1+
  • Laravel 9.0, 10.0, 11.0, 12.0
  • Google Translate API V2 (for google provider)
  • DeepL API (for deepl provider)

License

This package is open-sourced software licensed under the MIT license.

eii/laravel-ai-locale-generator 适用场景与选型建议

eii/laravel-ai-locale-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 eii/laravel-ai-locale-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 eii/laravel-ai-locale-generator 我们能提供哪些服务?
定制开发 / 二次开发

基于 eii/laravel-ai-locale-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-27