Releases: mantoufan/yzhanTranslator
Release Notes - Version 2.1.0
New Features
-
Images Descriptions: Introduced support for translating images by providing an array of image URLs. The translator now returns descriptions for each image in the specified language, enhancing the library's capabilities for handling visual content.
- Example:
$images = [ 'https://example.com/image1.jpg', 'https://example.com/image2.jpg', ]; $result = $translator->translate(json_encode($images), 'zh-CN', ['type' => 'images']);
- Example:
Improvements
- Updated the test suite to include cases for image translation, ensuring robust functionality and reliability.
Bug Fixes
- Minor bug fixes and performance improvements for better stability.
Documentation
- Updated the README to reflect the new image translation features and provide clear examples for users.
Release Notes - Version 2.0.2
YZhanTranslator Release Notes
Version 2.0.2
We're excited to announce the release of YZhanTranslator version 2.0.2! This update brings new features and improvements to enhance your translation and language detection capabilities.
New Features
-
Language JSON Detection:
- Added support for detecting the language of JSON content.
- Use the same
detect()
method with JSON input for seamless integration.
-
Enhanced Parameter Customization:
- Introduced more flexible configuration options for fine-tuning translations and caching.
Improvements
-
Expanded Documentation:
- Updated README with comprehensive parameter descriptions.
- Added examples for all major features, including the new JSON language detection.
-
Caching Enhancements:
- Improved caching options for better performance and cost savings.
- Added
maxAge
parameter for controlling cache expiration.
-
Timeout Control:
- Introduced
timeout
parameter for better control over API requests.
- Introduced
Detailed Changes
- Added
detect()
method support for JSON input. - Expanded
$params
array options intranslate()
anddetect()
methods:prompt
: For custom translation instructions.cache.type
: Specify caching mechanism (default: 'File').cache.params
: Configure cache-specific options.cache.params.dir
: Set custom directory for file-based caching.cache.maxAge
: Control cache expiration time.timeout
: Set custom request timeout (default: 6 seconds).
Upgrading
This release is fully backwards-compatible. To take advantage of the new features:
- Update YZhanTranslator in your project:
composer update mantoufan/yzhantranslator
- Refer to the updated README for new usage examples and parameter options.
Feedback
We value your input! If you encounter any issues or have suggestions for future improvements, please open an issue on our GitHub repository.
Thank you for using YZhanTranslator!
Release Notes - Version 1.1.0
Feature
- 🆕 Additional prompts can be used to customize the results, such as not translating the href attribute
- 🔧 Using
gpt-4o-mini
instead ofgpt-4o
, could usemodel
to customize - 🐛 Automatically clear cache when translation results cannot be obtained
1.0.0
Release Notes - Version 1.0.0
YZhanJSONTranslater
Release Date: October 4, 2024
New Features
-
JSON Translation with OpenAI:
- Translates the values of a JSON object to different languages while keeping the keys unchanged.
- Supports multiple languages using OpenAI's GPT-4 models.
-
Customizable API Client Configuration:
- Ability to configure OpenAI client settings, including API key, organization ID, and API URL.
-
Caching Mechanism:
- File-based caching: Reduce API calls and costs by caching translated results.
- Cache customization:
- Cache type: Currently supports
File
-based caching. - Cache parameters: Specify cache directory using the
params['dir']
field. - Cache expiration: Set cache expiration time in seconds using the
maxAge
field to control how long cache is valid.
- Cache type: Currently supports
-
Environment Variables Support:
- Configure OpenAI credentials through environment variables (
OPENAI_APIKEY
,OPENAI_APIURL
,OPENAI_ORGANIZATION
).
- Configure OpenAI credentials through environment variables (
Enhancements
- Improved API request efficiency by utilizing caching mechanisms.
- Enhanced translation accuracy and flexibility with OpenAI GPT-4 integration.
- Detailed cache control options for optimized API usage and response time.
Testing & Developer Tools
-
PHPUnit Integration:
- Unit tests for translation functionality.
- Cache-related test cases to ensure cache behavior works as expected.
-
Composer Scripts:
test
: Run unit tests usingphpunit
.coverage
: Generate test coverage reports.
Requirements
- PHP 5.4 or above.
- OpenAI API key and organization ID.
- Composer for managing dependencies.
Documentation
- Detailed usage instructions, including examples for translating JSON and configuring cache settings.
- Unit tests for translation and cache handling.
Known Issues
- Only
File
-based caching is supported in this release; additional cache types may be added in future releases.