visualbuilder/ai-translate
Composer 安装命令:
composer require visualbuilder/ai-translate
包简介
Translate localisation files with AI
README 文档
README
- 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.
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.
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 visualbuilder/ai-translate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Email Template editor for Filament
Configure scheduled routines for filament exporters
Effortlessly manage revisions of your Eloquent models in Filament with polymorphic user support (Fork of mansoor/filament-versionable).
Laravel artisan commands for YouTrack workflow automation — extracted so dev-agent and any consumer Laravel project share one source of truth.
A Filament v5 design-system review panel and AI-friendly theme designer.
Human QA review for Filament v5 screenshot catalogues — approve, request changes, and file tickets per capture.
统计信息
- 总下载量: 4.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-07-10


