Download the PHP package signifly/laravel-translator without Composer
On this page you can find all versions of the php package signifly/laravel-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download signifly/laravel-translator
More information about signifly/laravel-translator
Files in signifly/laravel-translator
Package laravel-translator
Short Description Database based translations for your Eloquent models.
License MIT
Homepage https://github.com/signifly/laravel-translator
Informations about the package laravel-translator
Database based translations for your Eloquent models
The signifly/laravel-translator
package allows you to easily add database based translations to your Eloquent models.
Below is a small example of how to use it:
In order to store translations, you can do the following:
You can also translate a single attribute:
If you want to update the model's attributes as well, it can be accomplished using:
The updateAndTranslate
method will detect if it is the default language and update accordingly.
Documentation
To get started follow the installation instructions below.
Installation
You can install the package via composer:
The package will automatically register itself.
You can publish the migration with:
Note: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the migration accordingly.
You can optionally publish the config file with:
This is the contents of the published config file:
Advanced
The package comes with a couple of middlewares that you might want to apply in order to get some extra functionality.
Auto Translation
You can enable this either by setting the auto_translate_attributes
to true
in the config or applying the Signifly\Translator\Http\Middleware\AutoTranslate
middleware to your routes.
For this to work you would also have to set the active_language_code
in the config.
Activate Language
This can inferred from the request if you apply the Signifly\Translator\Http\Middleware\ActivateLanguage
middleware to your routes.
However, you may also accomplish this manually by calling Translator::activateLanguage('en')
.
Testing
Security
If you discover any security issues, please email [email protected] instead of using the issue tracker.
Credits
- Morten Poul Jensen
- All contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-translator with dependencies
illuminate/console Version ^8.0|^9.0|^10.0
illuminate/database Version ^8.0|^9.0|^10.0
illuminate/support Version ^8.0|^9.0|^10.0