Download the PHP package devwizardhq/laravel-localizer without Composer
On this page you can find all versions of the php package devwizardhq/laravel-localizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devwizardhq/laravel-localizer
More information about devwizardhq/laravel-localizer
Files in devwizardhq/laravel-localizer
Package laravel-localizer
Short Description Laravel Localizer bridges Laravel translations to your SPA frontend (React/Vue/Inertia) and provides generated language assets, type-safe usage, and global translation helpers.
License MIT
Homepage https://github.com/devwizardhq/laravel-localizer
Informations about the package laravel-localizer
Laravel Localizer
Seamlessly bridge Laravel translations to your SPA frontend (React/Vue) with automatic TypeScript generation, type-safe usage, and powerful localization features.
Features
- 🔍 Auto-scan translations - Automatically discover translation keys from your codebase
- 🌐 Auto-translate - Use Google Translate to automatically translate missing keys
- 📦 TypeScript generation - Export translations as TypeScript files for frontend use
- 🎯 Type-safe - Full IDE support with PHPDoc annotations
- ⚡ Performance - In-memory caching and build-time generation
- 🔄 Vendor support - Automatically includes translations from vendor packages
- 🌍 RTL support - Built-in right-to-left language support
- 🎨 Framework agnostic - Works with React, Vue, and vanilla JavaScript
Installation
Install via Composer:
Run the installation command:
This interactive installer will:
- ✅ Publish configuration file
- ✅ Create default locale files
- ✅ Publish and register middleware
- ✅ Setup TypeScript output directory
- ✅ Generate initial translation files
Manual Setup
If you prefer manual configuration:
Register the middleware in bootstrap/app.php:
Quick Start
1. Configure Available Locales
Edit config/localizer.php:
2. Sync Translation Keys
Scan your codebase for translation keys:
This finds all __(), trans(), and lang() calls and adds missing keys to your language files.
3. Generate TypeScript Files
Export translations for your frontend:
Generates TypeScript files in resources/js/lang/:
4. Use in Frontend
Install the corresponding frontend package:
See the React package README or Vue package README for frontend integration details.
Usage
Commands
Sync Translation Keys
Auto-translate
Automatically translate from one locale to another using Google Translate:
Note: Requires stichoza/google-translate-php:
Generate TypeScript Files
Programmatic API
Middleware
The LocalizerMiddleware automatically:
- Detects user's preferred locale
- Sets the application locale
- Shares locale data with Inertia.js
Locale Detection Priority:
- Query parameter:
?locale=fr - Request header:
X-Locale: fr - Session: stored from previous requests
- User model:
$user->getLocale()(if method exists) - Browser:
Accept-Languageheader - Default:
config('localizer.default')
Shared Inertia Props:
Translation Organization
The package uses dot notation to organize translations:
- JSON keys (no dots):
welcome,hello world→ stored in{locale}.json - PHP keys (with dots):
validation.required,auth.failed→ stored in{locale}/{file}.php
Example structure:
Deployment
Generated Files
The installer automatically adds generated TypeScript files to .gitignore. In your deployment process, regenerate them:
Example CI/CD
Frontend Packages
Both packages provide:
- Hooks/composables for translations
- Vite plugin for automatic regeneration
- Full TypeScript support
- Inertia.js integration
- Placeholder replacement
- Pluralization support
Configuration
The config/localizer.php file provides extensive customization options:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- IQBAL HASAN
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-localizer with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/laravel-package-tools Version ^1.16