Download the PHP package rkwebsolution/translation-services without Composer
On this page you can find all versions of the php package rkwebsolution/translation-services. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rkwebsolution/translation-services
More information about rkwebsolution/translation-services
Files in rkwebsolution/translation-services
Package translation-services
Short Description Multi-service translation package for Laravel. Supports Google, Azure, DeepL, Yandex, Amazon, OpenAI, and Ollama through a unified manager, service provider, and facade
License MIT
Informations about the package translation-services
Translation Services Package
A comprehensive Laravel package for multi-service translation with support for Google Translate, Azure Translator, DeepL, OpenAI, Yandex Translate, Amazon Translate, and Ollama.
Features
- Multiple Translation Services: Supports 7 translation providers, including hosted APIs and local Ollama models
- Unified Interface: Single API for all services
- Spatie Translatable Integration: Works seamlessly with
spatie/laravel-translatable - Plug-and-Play: Easy service switching via configuration
- Batch Translation: Translate multiple texts efficiently
- Model Translation: Auto-translate model fields
- Error Handling: Robust error handling with standardized responses
- Caching Support: Reduce API calls and costs
- Fallback Support: Automatic fallback to alternative services
Installation
1. Add to composer.json
Since this is a local package, add it to your main project's composer.json:
2. Install the package
3. Publish configuration
4. Configure services
Edit config/translation-services.php or add to your .env:
Usage
Basic Translation
Using Specific Service
Batch Translation
Model Translation (Spatie Translatable)
Advanced Model Translation
Using Without Facade
Dependency Injection
Response Format
All translation methods return a standardized response:
Error Response
Check Available Services
Check Specific Service
Real-World Example
Translating Product Catalog
Command to Translate Models
Service-Specific Features
Google Translate
- Auto language detection
- Wide language support
- Fast and reliable
DeepL
- High-quality translations
- Free and Pro tiers
- Excellent for European languages
Azure Translator
- Microsoft's translation service
- Regional deployment
- High accuracy
OpenAI (ChatGPT)
- Context-aware translations
- Natural language understanding
- Flexible model selection (GPT-3.5/GPT-4)
Yandex Translate
- Good for Russian and Eastern European languages
- Cloud-based service
Amazon Translate
- AWS integration
- Custom terminology support
- Scalable
Ollama (Local AI)
- Local model-based translations through Ollama's OpenAI-compatible API
- No external translation API key required
- Configurable host, model, and timeout
Language Codes
Common language codes supported by most services:
en- Englishar- Arabices- Spanishfr- Frenchde- Germanit- Italianpt- Portugueseru- Russianzh- Chineseja- Japaneseko- Koreanhi- Hindiur- Urdu
Error Handling
Testing
The package includes robust error handling and logging. To test:
Cost Optimization
- Enable Caching: Cache translations to avoid repeated API calls
- Batch Translations: Use
translateBatch()when translating multiple texts - Choose Right Service: Different services have different pricing models
- Use Free Tiers: DeepL offers free tier, OpenAI has lower costs for GPT-3.5
Extending the Package
Adding a New Service
- Create service class in
src/Services/ - Implement
TranslationServiceInterface - Extend
BaseTranslationService - Add to
TranslationManager::driver()method - Add configuration in
config/translation-services.php
Version History
v1.1.0 - Ollama local AI translation support
- Added
ollamatranslation driver - Added Ollama environment and configuration options
- Updated service discovery and documentation for local AI translation
v1.0.0 - Initial release
- 6 hosted translation services
- Spatie Translatable integration
- Batch translation
- Model translation
License
MIT License
Support
For issues and feature requests, please contact the development team.
All versions of translation-services with dependencies
guzzlehttp/guzzle Version ^7.0
spatie/laravel-translatable Version ^6.5