Download the PHP package litepie/trans without Composer
On this page you can find all versions of the php package litepie/trans. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download litepie/trans
More information about litepie/trans
Files in litepie/trans
Package trans
Short Description A modern, production-ready, and well-documented PHP translation package with language negotiation and Laravel integration.
License MIT
Homepage https://github.com/litepie/trans
Informations about the package trans
Litepie Trans - Enhanced Laravel Translation Package
A modern, production-ready, and well-documented PHP translation package with advanced language negotiation, URL localization, route translation, and comprehensive Laravel integration. Now fully compatible with Laravel 12!
โจ Features
- ๐ Automatic Language Detection - Intelligent locale detection from Accept-Language headers
- ๐ URL-based Locale Switching - Clean, SEO-friendly localized URLs
- ๐ฃ๏ธ Route Translation - Translate route patterns and parameters
- โก Performance Optimized - Built-in caching and optimization for Laravel 12
- ๐ง Middleware Integration - Seamless Laravel 12 middleware support
- ๐ฏ Type Safe - Full PHP 8.1+ type declarations and strict types
- ๐ฑ Multi-directional Support - LTR and RTL language support
- ๐ช Session & Cookie Support - Remember user language preferences
- ๐งช Comprehensive Testing - Full test suite included
- ๐ Rich Documentation - Extensive documentation and examples
- ๐ Laravel 12 Ready - Fully compatible with the latest Laravel version
๐ Installation
Install the package via Composer:
Laravel Auto-Discovery
The package will automatically register its service provider and aliases.
Manual Registration (if needed)
Add the service provider to your config/app.php
:
Publish Configuration
Publish the configuration file:
โ๏ธ Configuration
The configuration file config/trans.php
provides extensive customization options:
๐ฏ Basic Usage
Setting Up Middleware
Add the localization middleware to your routes:
Using the Trans Service
Language Switcher in Blade Templates
Create a language switcher component:
๐ Advanced Features
Route Translation
Define translated routes in your language files:
Register translated routes:
Custom Language Negotiation
Locale Detection Priority
The package detects locale in this order:
- URL segment -
/es/page
(highest priority) - Session - Stored user preference
- Cookie - Persistent preference
- Accept-Language header - Browser preference
- Default locale - Fallback (lowest priority)
๐ง Middleware Options
LocalizationMiddleware
Automatically handles locale detection and URL redirection:
Custom Middleware Usage
๐ API Reference
Trans Class Methods
Locale Management
Locale Information
URL Generation
Utility Methods
LanguageNegotiator Class
๐งช Testing
Run the test suite:
Example Test
๐ Security Considerations
- โ Input Validation - All locale inputs are validated against supported locales
- โ XSS Protection - Output is properly escaped in Blade components
- โ CSRF Protection - Compatible with Laravel's CSRF middleware
- โ SQL Injection - No direct database queries, uses Laravel's query builder
๐ Performance Tips
-
Enable Route Caching:
-
Use Laravel's Route Caching:
- Optimize Config Loading:
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Development Setup
๐ Changelog
Please see CHANGELOG.md for recent changes.
๐ก๏ธ Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Credits
- Original Lavalite Team - For the foundation
- Laravel Community - For the amazing framework
- Contributors - All the people who have contributed to this project
๐ Links
Made with โค๏ธ by the Lavalite Team
All versions of trans 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/config Version ^9.0|^10.0|^11.0|^12.0
illuminate/translation Version ^9.0|^10.0|^11.0|^12.0
illuminate/routing Version ^9.0|^10.0|^11.0|^12.0