Download the PHP package subhashladumor1/laravel-translate without Composer
On this page you can find all versions of the php package subhashladumor1/laravel-translate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download subhashladumor1/laravel-translate
More information about subhashladumor1/laravel-translate
Files in subhashladumor1/laravel-translate
Package laravel-translate
Short Description ๐ Professional multi-source translation package for Laravel 11+ with free APIs (LibreTranslate, Lingva, MyMemory), smart caching, batch translation, CLI tools, and analytics dashboard. Zero API costs!
License MIT
Homepage https://github.com/subhashladumor1/laravel-translate
Informations about the package laravel-translate
โจ Why Laravel Translate?
๐ฏ Zero API Costs - Use completely free translation services (no API key needed!)
โก Lightning Fast - Smart caching reduces API calls by 90%+
๐ Bulletproof - Automatic fallback across 5 translation services
๐จ Developer Friendly - Blade directives, helpers, facades, CLI
๐ Production Ready - Built-in analytics and performance monitoring
๐ Truly Multilingual - Support 100+ languages out of the box
๐ Offline Capable - Works without internet using Argos
๐ SaaS Ready - Perfect for multi-tenant applications
๐ Features
| ### ๐ฅ Core Features - โ **5 Free Translation APIs** - Lingva Translate (Default - No API Key) - Google Free (No API Key) - MyMemory (No API Key) - LibreTranslate (Free tier available) - Argos (Offline) - โ **Auto Language Detection** - โ **Intelligent Fallback Chain** - โ **Batch Translation** - โ **Smart Caching System** | ### ๐ ๏ธ Developer Tools - โ **5 Powerful CLI Commands** - โ **Blade Directives** - โ **Helper Functions** - โ **Facade Support** - โ **Auto-Locale Middleware** - โ **Queue Integration** - โ **Analytics Dashboard** - โ **Translation Logging** - โ **Service Testing Tool** |
๐ฆ Installation
Step 1: Install via Composer
Step 2: Publish Configuration (Optional)
Step 3: Configure (Optional)
Add to your .env file:
That's it! ๐ The package works out-of-the-box with 3 services (Lingva, Google, MyMemory) - no API key required!
๐ Quick Start
๐ก Translate in 3 Ways
1๏ธโฃ Using Helper Function
2๏ธโฃ Using Facade
3๏ธโฃ In Blade Templates
๐ Complete Documentation
๐ฏ Basic Usage
Translate Text
Detect Language
Batch Translation
๐จ Blade Directives
@translate Directive
Block Translation
Forms with Translation
๐ง CLI Commands
1. Test Services
This command helps you:
- โ Verify which services are working
- โ Check API response times
- โ Diagnose connection issues
- โ See translation quality
2. Translate String
3. Translate Files
4. Sync Translations
5. Clear Cache
๐ฏ Advanced Features
Middleware - Auto Locale Detection
Register the middleware in your Laravel app:
Apply to routes:
The middleware automatically detects locale from:
- URL query parameter (
?lang=es) - User session
- Authenticated user's language preference
- Browser Accept-Language header
- GeoIP (optional)
Queue Integration
For large translation jobs:
Configure queue settings in config/translate.php:
๐ Analytics Dashboard
Access the beautiful analytics dashboard:
Monitor:
- ๐ Cache hit/miss rates
- โก API latency per service
- ๐ Recent translation logs
- ๐ฏ Service performance comparison
- ๐พ Storage efficiency
Protect the dashboard (recommended):
โ๏ธ Configuration
Service Configuration
Edit config/translate.php:
Cache Drivers
For Production (Redis - Recommended):
For Development (File):
For Database:
๐ Supported Translation Services
| Service | Speed | Quality | API Key | Offline | Rate Limit | Status |
|---|---|---|---|---|---|---|
| ๐ข Lingva | โกโกโกโก | โญโญโญโญ | โ No | โ | Generous | โ Default |
| ๐ข Google Free | โกโกโกโกโก | โญโญโญโญโญ | โ No | โ | Good | โ Active |
| ๐ก MyMemory | โกโก | โญโญโญ | โ No | โ | 1000/day | โ Active |
| ๐ก LibreTranslate | โกโกโก | โญโญโญโญ | โ ๏ธ Required | โ | 100K/mo free | โ๏ธ Optional |
| ๐ข Argos | โกโกโก | โญโญโญ | โ No | โ | Unlimited | โ๏ธ Optional |
Legend: โก = Fast | โญ = Quality Rating
Important Notes:
- Lingva, Google, MyMemory: Work out-of-the-box, no API key required
- LibreTranslate: Now requires free API key from portal.libretranslate.com
- Argos: Self-hosted, offline translation (requires installation)
๐ LibreTranslate API Key Setup (Optional)
LibreTranslate now requires an API key. Get one for FREE (100,000 characters/month):
Step 1: Get Free API Key
- Visit https://portal.libretranslate.com
- Sign up (no credit card required)
- Get your API key from dashboard
Step 2: Configure Laravel
Add to .env:
Step 3: Test
Alternative: Self-Host LibreTranslate
Then configure:
๐ Offline Translation (Argos)
Setup Argos Translate for offline use:
-
Install Argos:
-
Run Argos server:
- Enable in config:
Perfect for:
- Air-gapped environments
- Privacy-sensitive applications
- No internet dependency
- Unlimited translations
๐ผ Real-World Examples
E-commerce Product Translation
Multi-Language Blog
Dynamic Contact Form
Automated Language File Sync
๐ API Reference
Facade Methods
Translate::translate()
Translates text to the target language.
Translate::translateBatch()
Translates multiple texts at once.
Translate::detectLanguage()
Detects the language of given text.
Translate::clearCache()
Clears all translation cache.
Translate::getAnalytics()
Returns analytics data including cache stats and latency.
Helper Functions
| Function | Description | Example |
|---|---|---|
translateText() |
Translate text | translateText('Hello', 'es') |
translate() |
Full translation | translate('Hello', 'fr') |
translate_batch() |
Batch translate | translate_batch(['Hi', 'Bye'], 'de') |
detect_language() |
Detect language | detect_language('Bonjour') |
translate_array() |
Array translation | translate_array($data, 'es') |
Blade Directives
| Directive | Usage | Example |
|---|---|---|
@translate |
Inline translation | @translate('Welcome', 'es') |
@translateStart/@translateEnd |
Block translation | @translateStart('fr') ... @translateEnd |
@detectLang |
Detect language | @detectLang($text) |
Artisan Commands
| Command | Description |
|---|---|
translate:test |
Test all translation services |
translate:string {text} {target} |
Translate a string |
translate:file {source} {target} |
Translate entire file |
translate:sync --source=en --target=es,fr |
Sync translations |
translate:clear-cache |
Clear cache |
๐ฏ Supported Languages
100+ languages supported including:
ar Arabic โข bn Bengali โข zh Chinese โข cs Czech โข da Danish โข nl Dutch โข en English โข fi Finnish โข fr French โข de German โข el Greek โข he Hebrew โข hi Hindi โข hu Hungarian โข id Indonesian โข it Italian โข ja Japanese โข ko Korean โข ms Malay โข no Norwegian โข pl Polish โข pt Portuguese โข ro Romanian โข ru Russian โข es Spanish โข sv Swedish โข th Thai โข tr Turkish โข uk Ukrainian โข ur Urdu โข vi Vietnamese
And many more! Check service documentation for complete list.
๐ Performance & Benchmarks
Translation Speed
| Operation | Without Cache | With Cache | Improvement |
|---|---|---|---|
| Single Translation | ~150ms | ~1ms | 150x faster |
| Batch (50 items) | ~3000ms | ~50ms | 60x faster |
| File Translation | ~5000ms | ~100ms | 50x faster |
Cache Hit Rates
In production environments with proper caching:
- ๐ Average cache hit rate: 85-95%
- โก Average response time: 2-5ms
- ๐พ Storage overhead: Minimal
๐ก๏ธ Security
Best Practices
Data Privacy
- โ ๏ธ Text is sent to third-party APIs
- โ No data stored on our servers
- โ HTTPS encryption for all requests
- โ Use Argos for sensitive data (offline)
- โ Cache can be encrypted
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Quick Contribution Steps
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Troubleshooting
LibreTranslate API Key Error?
If you see: "Visit https://portal.libretranslate.com to get an API key"
Solution 1: Use services that don't require API key (Default)
Solution 2: Get free LibreTranslate API key
- Visit https://portal.libretranslate.com
- Sign up (100,000 characters/month FREE)
- Add to
.env:
Solution 3: Self-host LibreTranslate
Translations not working?
- Test services:
php artisan translate:test - Check internet connectivity
- Verify services are enabled in config
- Clear cache:
php artisan translate:clear-cache - Check logs:
storage/logs/laravel.log
Cache not working?
Dashboard not accessible?
Make sure routes are loaded and middleware is not blocking access.
Need Help?
- ๐ Read the documentation above
- ๐ Report bugs
- ๐ฌ Ask questions
- ๐ง Email: [email protected]
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Credits
- Author: Subhash Ladumor
- Translation APIs: LibreTranslate, Lingva, MyMemory, Google, Argos
- Community: All our amazing contributors
โญ Show Your Support
If you find this package helpful, please consider:
- โญ Starring the repository
- ๐ฆ Sharing on social media
- ๐ Writing a blog post
- ๐ฌ Telling your friends
Ready to make your Laravel app multilingual? Install now and start translating! ๐
All versions of laravel-translate with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/http Version ^9.0|^10.0|^11.0|^12.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.0
illuminate/session Version ^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0
illuminate/view Version ^9.0|^10.0|^11.0|^12.0
guzzlehttp/guzzle Version ^7.0