Download the PHP package nabila/laravel-translation-sync without Composer
On this page you can find all versions of the php package nabila/laravel-translation-sync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nabila/laravel-translation-sync
More information about nabila/laravel-translation-sync
Files in nabila/laravel-translation-sync
Package laravel-translation-sync
Short Description A Laravel package to detect untranslated strings and automatically translate them using various translation services like Google Translate, DeepL, and more.
License
Homepage https://github.com/Nabilaahmed2000/laravel-translation-sync
Informations about the package laravel-translation-sync
Laravel Translation Sync
A powerful Laravel package that automatically detects untranslated strings in your application and provides automatic translation capabilities using free translation services.
โจ Features
- ๐ Smart Detection: Scans your entire Laravel application for untranslated strings
- ๐ Free Auto Translation: Uses LibreTranslate and MyMemory (completely free, no API keys needed!)
- ๐ Translation Statistics: Get detailed insights about your translation coverage
- ๐ง Flexible Configuration: Customizable scan paths, file formats, and translation patterns
- ๐ฏ Multiple File Formats: Support for both JSON and PHP translation files
- ๐ฑ Rich Console Interface: Beautiful command-line interface with progress indicators
- ๐ก๏ธ Safe Operation: Dry-run mode to preview changes before applying them
๐ Quick Start (5 minutes!)
1. Install the Package
2. Publish Configuration
3. Start Translating! (No API keys needed!)
That's it! ๐ Your Laravel app now has automatic translation capabilities using completely free services.
Requirements
- PHP: >= 8.0
- Laravel: 9.x, 10.x, 11.x, 12.x
- Composer: Latest stable version
๐ Quick Start (5 minutes!)
Installation
Install the package via Composer:
Publish the configuration file:
โก Zero-Configuration Setup
The package comes pre-configured to work with free translation services. No API keys, no billing setup required!
Start using it immediately:
๐งช Testing Your Installation
After installation, test that everything works:
Configuration
The package comes with a comprehensive configuration file. Here are the key settings:
Environment Variables
Add these to your .env file:
๐ No billing, no API keys, no setup required! The package uses free translation services by default.
๐ Need help getting a Google Translate API key? Check out our Quick Setup Guide for step-by-step instructions!
Usage
Basic Scanning
Scan for missing translations:
Automatic Translation
Enable automatic translation with the --translate flag:
Advanced Options
Translation Services
๐ Free Services (No API Keys Required!)
LibreTranslate (Default - Recommended)
Completely free, open-source translation service
- โ No API key required
- โ No billing needed
- โ Open source and self-hosted
- โ Supports 50+ languages
- โ Fast and reliable
MyMemory
Community-driven translation service
- โ No API key required
- โ No billing needed
- โ Community translations
- โ Supports 80+ languages
๐ฐ Paid Services
Google Translate
Professional translation service
- โ High quality translations
- โ Supports all major languages
- โ ๏ธ Requires billing setup
- โ ๏ธ API key required
๐ Need help with Google Translate API? Check out our Quick Setup Guide
Follow these steps to obtain your Google Translate API key:
-
Go to Google Cloud Console
- Visit Google Cloud Console
- Sign in with your Google account
-
Create or Select a Project
- Click on the project dropdown at the top
- Either select an existing project or click "New Project"
- If creating new: Enter project name and click "Create"
-
Enable the Cloud Translation API
- In the left sidebar, go to "APIs & Services" > "Library"
- Search for "Cloud Translation API"
- Click on "Cloud Translation API" from the results
- Click the "Enable" button
-
Create API Credentials
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "API key"
- Your API key will be generated and displayed
- Important: Copy and save this key securely
-
Secure Your API Key (Recommended)
- Click on the API key name to edit it
- Under "API restrictions", select "Restrict key"
- Choose "Cloud Translation API" from the list
- Under "Application restrictions", you can:
- Set HTTP referrers for web apps
- Set IP addresses for server apps
- Or leave unrestricted for development
-
Set Up Billing (Required)
- Google Translate API requires a billing account
- Go to "Billing" in the left sidebar
- Link a billing account or create a new one
- Note: Google provides free credits for new accounts
- Add to Your Environment
Pricing Information
- Free Tier: $300 in free credits for new Google Cloud accounts
- Cost: $20 per 1 million characters translated
- Monthly Free Usage: First 500,000 characters per month are free
- Check current pricing at Google Cloud Pricing
API Limits
- Default Quota: 1,000,000 characters per 100 seconds
- Character Limit: 30,000 characters per request
- Rate Limit: Can be increased by requesting quota increases
๐งช Testing Service
Dummy Service
For development and testing
The dummy service is useful for testing and development. It simply appends the target language code to the original text.
๐ Using FreeTranslateApi (Self-hosted, Free)
1. Host the API
- Clone https://github.com/ismalzikri/free-translate-api
- Follow its README to run locally (
npm install && npm start) or deploy to a server.
2. Configure the Package
-
In your
.envfile, set:(Change the URL if hosted elsewhere.)
- In
config/translation-sync.php, ensure:
3. Usage
- Run your translation sync commands as usual.
- The package will use your FreeTranslateApi instance for translations.
4. Notes
- FreeTranslateApi is free and self-hosted, so you control usage and limits.
- Make sure your API server is running and accessible from your Laravel app.
Supported Translation Patterns
The package automatically detects these translation patterns in your code:
__('key')- Laravel's__()helper@lang('key')- Blade directivetrans('key')- Laravel'strans()helperLang::get('key')- Facade usage
File Formats
JSON Format (default)
PHP Format
Advanced Features
Translation Statistics
Get detailed statistics about your translation coverage:
This shows:
- Total translation keys found
- Missing translations
- Coverage percentage
- Translation service status
Context-Aware Detection
The package provides context for each missing translation, showing:
- Files where the translation key was found
- Code context around the usage
- Multiple occurrences across your application
Placeholder Preservation
The package intelligently handles Laravel translation placeholders:
Examples
Basic Usage
Run the sync command:
This will:
- Detect the missing translations
- Automatically translate them to your configured target languages
- Save them to your translation files
Configuration Example
Troubleshooting
Common Issues and Solutions
1. Google Translate API Key Issues
Problem: "Google Translate service is not properly configured"
Solutions:
- Verify your API key is correct in
.envfile - Ensure the Cloud Translation API is enabled in Google Cloud Console
- Check that billing is set up for your Google Cloud project
- Verify your API key has the correct restrictions (if any)
Test your API key:
2. Permission Issues
Problem: "Failed to create translation file" or permission errors
Solutions:
3. Missing Translations Not Detected
Problem: Known untranslated strings are not being found
Solutions:
- Check if your translation patterns are in the scan paths
- Verify file extensions are included in configuration
- Use custom patterns for non-standard translation methods:
4. Quota Exceeded Errors
Problem: "Quota exceeded" or rate limit errors
Solutions:
- Check your Google Cloud Console quotas
- Request quota increases if needed
- Use smaller batches with the
--dry-runflag first - Consider using the dummy service for development:
5. Composer Dependencies
Problem: Package installation fails
Solutions:
6. Configuration Not Loading
Problem: Configuration changes not taking effect
Solutions:
Debugging Commands
Environment Validation
Create a simple test to validate your setup:
Error Handling
The package includes comprehensive error handling:
- Translation Service Errors: Falls back to original text or configured fallback strategy
- File Permission Issues: Clear error messages with suggested solutions
- API Quota Limits: Graceful handling with retry suggestions
- Network Issues: Timeout handling and fallback options
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This package is open-sourced software licensed under the MIT license.
Support
If you discover any security vulnerabilities or bugs, please send an e-mail to the package maintainer.
Changelog
v2.0.1 (Compatibility Update)
- ๐ง Broader Laravel Support: Now compatible with Laravel 9.x, 10.x, 11.x, and 12.x
- ๐ฆ Updated Dependencies: More flexible version constraints for better compatibility
- ๐งช Enhanced Testing: Support for multiple PHPUnit and Testbench versions
v2.0.0 (Enhanced Version)
- โจ FREE Translation Services: Added LibreTranslate and MyMemory (no API keys needed!)
- ๐ Zero-Configuration: Works out-of-the-box with free services
- ๐ฆ Packagist Ready: Proper versioning and composer configuration
- ๐ง Enhanced Configuration: LibreTranslate as default free service
- ๐ฏ Improved Documentation: Clear installation and usage guides
- ๐งช Better Testing: Support for free service testing
v1.0.0 (Original Version)
- ๐ Basic translation key detection
- ๐ Simple file writing capabilities
- ๐ฏ Basic console command
All versions of laravel-translation-sync with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
guzzlehttp/guzzle Version ^7.0
stichoza/google-translate-php Version ^5.0