Download the PHP package smartness/translation-client without Composer
On this page you can find all versions of the php package smartness/translation-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smartness/translation-client
More information about smartness/translation-client
Files in smartness/translation-client
Package translation-client
Short Description Laravel package to sync translations with SmartPMS Translation Manager
License MIT
Informations about the package translation-client
Smartness Translation Client
A Laravel package to synchronize translations between your Laravel application and a centralized translation management system. Pull translations from the server or push local translations back to keep everything in sync.
Features
- 🚀 One Command Install - Get started in seconds
- 🔄 Bi-directional Sync - Pull and push translations with simple commands
- 🌍 Multi-language - Support for all languages
- 📦 Laravel Compliant - Generates proper Laravel translation files with nested arrays
- ⚡ CI/CD Ready - Perfect for automated deployments
- 🔒 Secure - API token authentication
- 🎯 Smart Filtering - Filter by language, status, or specific files
- ⬆️ Push Support - Send local translations back to the server
- 🔎 Source-Code Sync -
translations:missingandtranslations:cleanupreconcile the catalog with the actual$t()/trans()/__()/@langusage in your code - 🏠 Centralized Scan Config - Scan settings live on the project so every developer uses the same patterns (local
.envstill wins)
Requirements
- PHP 8.1 or higher
- Laravel 10, 11, 12, or 13
Installation
Install via Composer:
The package will automatically register itself via Laravel's package auto-discovery.
Configuration
Step 1: Publish Configuration (Optional)
This creates a config/translation-client.php file where you can customize settings.
Step 2: Configure Environment Variables
Add these variables to your .env file:
Note: You'll receive your API token and endpoint URL from your translation service administrator.
Usage
Pulling Translations (Download)
Pull all translations from the server:
Pull translations for a specific language:
Preview changes without saving (dry-run):
Test API connection:
Advanced Pull Options
Pushing Translations (Upload)
Push all local translations to the server:
Push translations for a specific language:
Push a specific translation file:
Preview without actually pushing:
Overwrite existing translations on the server:
Use a custom translation directory:
Advanced Push Options
Reconciling the Catalog with Source Code
These two commands scan your local source for $t('…'), useTranslate('…'), i18n.t('…'), trans('…'), __('…') and @lang('…') calls and reconcile what they find with what the server stores.
Both commands first fetch the project's central scan configuration from GET /translation-projects/config. Local config (config/translation-client.php or SMARTPMS_TRANSLATION_* env vars) always wins; the server values are a shared default; package defaults are used if neither is set. The resolved config is printed at the start of each run so you can verify which source provided each value.
translations:missing — Find Keys Used in Code but Absent Remotely
Sample output:
translations:cleanup — Find Keys Stored Remotely but Unused in Code
Dynamic keys built with template literals (e.g. $t(`amenities.${name}`)) contribute a static prefix that protects every matching remote key from deletion — no false positives when the key set is computed at runtime.
Output Structure
The package creates translation files following Laravel's standard structure:
Example Generated File
Programmatic Usage
You can use the Translation Client directly in your code:
Available Methods
| Method | Description | Returns |
|---|---|---|
fetchAsPhp(?string $language) |
Fetch translations as nested PHP arrays (Laravel format) | array |
fetchAsJson(?string $language) |
Fetch translations as flat JSON structure | array |
fetchRaw(?string $language) |
Fetch raw format with full metadata | array |
fetch(array $options) |
Fetch with custom options | array |
push(array $translations, array $options) |
Push translations to the server | array |
pushLanguage(string $language, array $translations, bool $overwrite) |
Push translations for a specific language | array |
pushFile(string $language, string $filename, array $translations, bool $overwrite) |
Push a specific translation file | array |
fetchProjectConfig() |
Fetch the centralized scan config from the server. Returns null on failure so callers can fall back to local config. |
?array |
cleanup(array $usedKeys, array $usedPrefixes, bool $delete) |
Report (and optionally delete) remote keys not referenced in source. | array |
discoverMissing(array $usedKeys, array $usedPrefixes, bool $insert) |
Report (and optionally insert) keys referenced in source but missing remotely. | array |
testConnection() |
Verify API connection and token | bool |
CI/CD Integration
GitHub Actions
Add this workflow to automatically sync translations:
GitLab CI
Configuration Reference
All configuration options available in config/translation-client.php:
Error Handling
The package provides clear, actionable error messages:
Troubleshooting
"API token not configured"
Solution: Add your API token to .env:
"Authentication failed"
Solution: Verify your API token is correct. Contact your translation service administrator if needed.
"Connection timeout"
Solutions:
- Check your network connection
- Verify the API URL is correct
- Increase timeout:
TRANSLATION_TIMEOUT=60
Translations not updating
Solutions:
- Run with
--dry-runto preview changes - Check status filter:
--status=approved - Verify you have translations in the system
Advanced Usage
Custom Fetch Options
Custom Output Directory
Multiple Environments
Security
- ✅ API token authentication
- ✅ HTTPS required for API communication
- ✅ Token validation before requests
- ✅ No sensitive data in logs
Important: Never commit your API token to version control. Always use environment variables.
Support
For issues, questions, or feature requests:
- Email: [email protected]
- Issues: GitHub Issues
License
The MIT License (MIT). Please see License File for more information.
Credits
- Smartness Team
- All Contributors
All versions of translation-client with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.0