承接 eii/locale-generator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

eii/locale-generator

最新稳定版本:v1.1.0

Composer 安装命令:

composer require eii/locale-generator

包简介

A Laravel CLI to extract and translate Blade file strings to JSON language files

README 文档

README

Locale Generator is a Laravel Artisan command that simplifies multilingual development by automatically extracting __() strings from Blade templates and generating JSON language files.
It optionally integrates with Google Cloud Translate or DeepL to provide instant translations, helping you speed up localization workflows.

Installation

composer require eii/locale-generator

Setup

  1. Publish Configuration:

    php artisan vendor:publish --tag=config
  2. Configure Translation Providers:

    • Google Cloud Translate:
      • Create a Google Cloud service account and download the JSON key file.
      • Place the key file in storage/app/google-credentials.json or update the path in config/locale-generator.php.
      • Add to .env:
        GOOGLE_TRANSLATE_KEY_FILE=/path/to/google-credentials.json
        GOOGLE_PROJECT_ID=your-project-id
    • DeepL:
      • Obtain a DeepL API key (free tier available).
      • Add to .env:
        DEEPL_API_KEY=your-deepl-api-key

Usage

Run the lang:extract command:

php artisan lang:extract welcome --locales=ja,es,de --translate=google
php artisan lang:extract mail.notification --locales=fr,es --translate=deepl
  • file: Blade file name (e.g., welcome, mail.notification).
  • --locales: Comma-separated list of target locales (e.g., ja,es,de).
  • --translate: Translation provider (google or deepl).

Configuration

Edit config/locale-generator.php to customize:

  • views_path: Directory for Blade files (default: resources/views).
  • google_translate.key_file: Path to Google Cloud service account JSON key.
  • google_translate.project_id: Google Cloud project ID.
  • deepl_api_key: DeepL API key.

Requirements

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

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-07