定制 visualbuilder/ai-translate 二次开发

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

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

visualbuilder/ai-translate

Composer 安装命令:

composer require visualbuilder/ai-translate

包简介

Translate localisation files with AI

README 文档

README

Latest Version on Packagist Total Downloads run-tests Check & fix styling

Example

  • Just set a list of languages that you would like your site translating to and leave it to GPT.
  • Can use GPT-3.5-turbo or GPT-4
  • Estimates cost before running
  • More accurate than Google Translate
  • Handles variables in the translation string - they will not be translated.
  • Handles both PHP and JSON files
  • Model translations coming soon

Examples

Examples:- From English:

  • 'accepted' => 'The :attribute must be accepted.',
  • 'accepted_if' => 'The :attribute must be accepted when :other is :value.',

To Arabic:-

  • 'accepted' => 'يجب قبول الـ :attribute',
  • 'accepted_if' => 'يجب قبول الـ :attribute عندما يكون الـ :other هو :value',

To Ukrainian:-

  • 'accepted' => ':attribute має бути прийнятий.',
  • 'accepted_if' => ':attribute має бути прийнятий, коли :other є :value.',

To German:-

  • 'accepted' => 'Die :attribute müssen akzeptiert werden.',
  • 'accepted_if' => 'Die :attribute müssen akzeptiert werden, wenn :other :value ist.',

To Spanish:-

  • 'accepted' => 'El :attribute debe ser aceptado.',
  • 'accepted_if' => 'El :attribute debe ser aceptado cuando :other es :value.',

To Chinese Simplified:-

  • 'accepted' => ':attribute必须被接受。',
  • 'accepted_if' => '当:attribute是:other时,:value必须被接受。',

To Swedish:-

  • 'accepted' => ':attribute måste accepteras.',
  • 'accepted_if' => ':attribute måste accepteras när :other är :value.',

Requirements

PHP 8.1 Is the minimum for the OpenAI Wrapper.

Tested with Laravel ^9.45 and 10.x

Filament is not required (but can add to their already awesome set of translations.)

Installation

Download the package via composer:

composer require visualbuilder/ai-translate

Run the install to copy the config files:-

php artisan vb:ai:install

This will create config/ai-translate.php and config/openai.php if it isn't already installed.

If you don't have GPT keys already visit: https://platform.openai.com/account/api-keys

Add these keys to your .env

OPENAI_API_KEY=sk-xxxxxxx
OPENAI_ORGANIZATION=org-xxxxxx

Usage

Check the config file to make sure you have included the required source locale directories. Copy from the list of known_locales the languages you wish to translate into the target_locales array.

Currently handles .json and .php translation files. Attribute tokens should remain unchanged. This was a challenge as GPT-3.5 refused to ignore :attribute and always translated it even when told explicity to ignore it. To solve this all tokens are replaced with *** before translation and added back in after translation ensuring continuity.

php artisan vb:ai:translate --help

To run the script:-

php artisan vb:ai:translate

The script will scan all the source_directories for translation files and then provide an estimate of the cost to translate into the required languages for each GPT Model.

If you're happy to continue, select the model you wish to use and each source file will be translated.

php artisan vb:ai:translate

If the target file exists, only new keys not in the target will be translated. Unless you use the --force option which will overwrite any existing translations.

I will be adding additional capabilities for model translations and for Spatie Language lines. I have these in a couple of projects so want to extend features.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email support@ekouk.com instead of using the issue tracker.

Credits

License

The GNU GPLv3. Please see License File for more information.

visualbuilder/ai-translate 适用场景与选型建议

visualbuilder/ai-translate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.36k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2023 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「visualbuilder」 「ai-translate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 visualbuilder/ai-translate 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-07-10