internetguru / laravel-translatable
Installs: 492
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/internetguru/laravel-translatable
Requires
- laravel/framework: ^11.0
Requires (Dev)
- laravel/pint: ^1.18
- orchestra/testbench: ^9.5
- phpunit/php-code-coverage: ^11.0
This package is auto-updated.
Last update: 2026-01-25 21:18:36 UTC
README
A Laravel package for translating Eloquent model attributes.
| Branch | Status | Code Coverage |
|---|---|---|
| Main | ||
| Staging | ||
| Dev |
Installation
-
Install the package via Composer:
# First time installation composer require internetguru/translatable # For updating the package composer update internetguru/translatable
Run Tests Locally
In Visual Studio Code you can simpy use Ctrl+Shift+B to run the tests.
To run the tests manually, you can use the following commands:
# Build the Docker image docker build -t laravel-translatable . # Run the tests docker run --rm laravel-translatable # Both steps combined docker build -t laravel-translatable . && docker run --rm laravel-translatable
Usage
-
Add the
Translatabletrait to your Eloquent model:use InternetGuru\Translatable\Translatable; class Room extends Model { use Translatable; }
-
Define the translatable attributes in the model. Do not use
$fillablefor translatable attributes:protected $translatable = ['name'];
-
Use translatable attributes:
app()->setLocale('en'); app()->setFallbackLocale('en'); $room = new Room(); $room->save(); // No translation set echo $room->name; // null $room->name = 'Living Room'; echo $room->name; // Living Room app()->setLocale('cs'); $room->name = 'Obývací pokoj'; echo $room->name; // Obývací pokoj app()->setLocale('en'); echo $room->name; // Living Room app()->setLocale('cs'); echo $room->name; // Obývací pokoj // Fallback to the fallback locale app()->setLocale('de'); echo $room->name; // Living Room // Fallback to the first translation if fallback locale not found app()->setFallbackLocale('fr'); echo $room->name; // Living Room
License & Commercial Terms
Open Source License
Copyright © 2026 Internet Guru
This software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.
Disclaimer: This software is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability.
Commercial Use
The standard CC BY-NC-SA license prohibits commercial use. If you wish to use this software in a commercial environment or product, we offer flexible commercial licenses tailored to:
- Your company size.
- The nature of your project.
- Your specific integration needs.
Note: In many instances (especially for startups or small-scale tools), this may result in no fees being charged at all. Please contact us to obtain written permission or a commercial agreement.
Contact for Licensing: info@internetguru.io
Professional Services
Are you looking to get the most out of this project? We are available for:
- Custom Development: Tailoring the software to your specific requirements.
- Integration & Support: Helping your team implement and maintain the solution.
- Training & Workshops: Seminars and hands-on workshops for your developers.
Reach out to us at info@internetguru.io — we are more than happy to assist you!