Download the PHP package upon/mlang without Composer
On this page you can find all versions of the php package upon/mlang. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package mlang
Short Description Multilanguage package working for large databases, and fast response
License MIT
Informations about the package mlang
High-Performance Multi-Language Package for Laravel
This package is a high-performance solution designed to provide efficient multi-language support for Laravel applications. It offers robust features and optimizations to ensure fast and reliable language management, making your application accessible to a global audience without sacrificing performance.
Features
- Accelerated translation retrieval: Translation strings are efficiently retrieved from the same database table, minimizing database join queries and improving response times.
-
Seamless integration with Laravel: The package integrates seamlessly with Laravel, leveraging its existing localization infrastructure while providing performance enhancements.
- Translation helpers: You can use helper functions and methods to translate your application's content into different languages. These helpers make it easy to retrieve and display translated strings.
- Language detection: The package includes automatic language detection based on the user's browser settings. It also supports manual language selection for users.
- Language fallbacks: If a translation is missing for a specific language, the package supports fallbacks to default or alternative languages. This ensures that users always see content in a supported language.
Notice
This package will add two extra columns to the model you will use, row_id and iso. The package will use the row_id as id, to grep the right row from the db.
- row_id: This column will hold the main primary key for you on all languages.
-
iso: This column holding the language key, e.g. en,nl,fr,etc...
Requirements
- PHP >= 8.1
- Laravel >= 10.0
This package requires the following package.
Installation
1 - Install the package using Composer:
2 - Publish the package configuration and language files:
3 - Configure the package by modifying the config/mlang.php
file according to your requirements.
You can specify the supported locales, default locale, models, and other options.
4 - Configure in your mlang config file the needed model for translations.
5- Replace the default extended Model with the MlangModel
.
6 - Run the migration command to migrate the new columns, to the added models.
Managing Translations to existing records
-
To generate translations for existing rows, use the following command:
-
To generate in a specific table, use the following command:
-
To generate a specific language code, use the following command:
-
To delete a language from table, use the following command:
- The package includes automatic language detection based on the user's browser's language. It uses the Accept-Language header or browser settings to determine the preferred language.
- (Optional) Add the locale middleware to your app/Http/Kernel.php file in the $middlewareGroups property: To detect the user browser language.
To manually set the language for a user, you can use the setLocale() method:
Usage
To find a record from db by id, you can use the following. \ This will get the translated record based on the current language has been used by your application.
The trWhere method will work like the normal where but will map the id
to row_id
column to be able selecting the current language.
This will return a build, so you can chain on it with other query.
Contributing
Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute to the package, please create an issue or submit a pull request on the package's GitHub repository.
License
This package is open-source software licensed under the MIT license. Feel free to use, modify, and distribute it as per the terms of the license.
Credits
This package was developed by Reymon Zakhary. Special thanks to the Laravel community for their support and inspiration.
Contact
If you have any questions or need further assistance, you can reach out to the package maintainer at [email protected].
All versions of mlang with dependencies
ext-filter Version *
illuminate/database Version ^10.13|11.*
illuminate/support Version ^10.13|11.*