定制 quarkinocom/laravel-translation-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

quarkinocom/laravel-translation-manager

最新稳定版本:v0.0.4

Composer 安装命令:

composer require quarkinocom/laravel-translation-manager

包简介

A Laravel Artisan command package to manage and automate language translations, leveraging OpenAI for high-quality translations.

README 文档

README

The Laravel Translation Manager is an Artisan command suite designed for managing and automating the translation process in Laravel applications. Utilizing the OpenAI API, this package simplifies tasks such as displaying, comparing, translating, and repairing language files across different languages, making it a must-have for developers working on multilingual projects.

Installation

To get started, install the package through Composer:

composer require quarkinocom/laravel-translation-manager

This command automatically installs the package and registers its service provider via Laravel's package discovery.

Publishing Configuration

To customize the package's settings, such as specifying your OpenAI API key, publish the configuration file:

php artisan vendor:publish --provider="Quarkinocom\TranslationManager\TranslationManagerServiceProvider" --tag="config"

This command copies the translation-manager.php configuration file to your project's config directory.

Usage

The package introduces several Artisan commands to streamline language file management:

Show Command

Display a list of all translation files for a specified language, including the count of translation keys.

Usage:

php artisan language:translate show {language}

Sample Command:

php artisan language:translate show en

Expected Output:

+---------------------+---------------+-------+
| Directory           | File          | Keys  |
+---------------------+---------------+-------+
| /resources/lang/en  | messages.php  | 10    |
| /resources/lang/en  | validation.php| 42    |
+---------------------+---------------+-------+
Total files: 2

Compare Command

Compare translation files between two languages, highlighting missing or empty keys.

Usage:

php artisan language:translate compare {source-language} {target-language}

Sample Command:

php artisan language:translate compare en fr

Expected Output:

+---------------------+-----------+-----------------------+
| File                | Key       | Status                |
+---------------------+-----------+-----------------------+
| messages.php        | welcome   | Missing in target     |
| validation.php      | required  | Empty value in target |
+---------------------+-----------+-----------------------+
Differences detected: 2

Translate Command

Translate missing or empty keys from the source language to the target language. Optionally, create or update translation files.

Usage:

  • To translate all keys:
php artisan language:translate translate {source-language} {target-language}
  • To repair (translate only missing or empty keys):
php artisan language:translate repair {source-language} {target-language}

Sample Command:

php artisan language:translate translate en fr

Expected Result: This command will output the number of keys translated and API calls made, without a specific table format as the result is dependent on the translations performed.

Git Repository

Explore or contribute to Laravel Translation Manager on GitHub:

https://github.com/quarkinocom/laravel-translation-manager

Contributing

Contributions are welcome and greatly appreciated! Feel free to fork the repository, make your changes, and submit a pull request. For substantial changes, please open an issue first to discuss what you would like to change. Remember to update tests as needed.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-16