michalskoula / codeigniter-ai-translation
此包允许您使用Anthropic Claude REST API将CodeIgniter 3/4语言文件翻译成任何语言。
1.0.1
2024-09-17 20:01 UTC
Requires
- php: >=8.1
- mozex/anthropic-php: ^1.0
- nyholm/psr7: ^1.8
- symfony/http-client: ^6.4
Requires (Dev)
- rector/rector: ^0.17.6
- symplify/easy-coding-standard: ^11.5
This package is auto-updated.
Last update: 2024-09-18 06:17:33 UTC
README
使用Anthropic Claude REST API将CodeIgniter 3/4语言文件翻译成任何语言。
它会自动添加缺失的翻译(数组元素),因此您可以定期运行它以更新语言文件。也支持多维数组。
安装
composer require michalskoula/codeigniter-ai-translation
需要PHP 8.1+
使用方法
<?php require_once __DIR__ . '/vendor/autoload.php'; $translator = new MichalSkoula\CodeIgniterAITranslation\Translator( 'your-api-key', // Anthropic Claude API key 'cs', // source language (need to match you directory name) 'en', // target language (need to match you directory name; will be created automatically) 'application/language', // path to your language files 3 // CodeIgniter version (3 - default, 4) ); // if $file is null, if will translate all files in the directory $result = $translator->translate($file); echo "Translation process completed." . PHP_EOL; echo "Total files processed: " . $result->getProcessed() . PHP_EOL; echo "Total items translated: " . $result->getTranslated() . PHP_EOL; echo "Total items failed: " . $result->getFailed() . PHP_EOL; if ($result->isError()) { echo 'Error: ' . $result->getErrorMessage() . PHP_EOL; }