berthott/laravel-translatable is a Laravel package for laravel helper for model translations.
It currently has 0 GitHub stars and 718 downloads on Packagist (latest version 3.0.5).
Install it with composer require berthott/laravel-translatable.
Discover more Laravel packages by berthott
or browse all Laravel packages to compare alternatives.
Last updated
A helper for Model Translations in Laravel.
Easily add translatable fields to any of your eloquent models.
$ composer require berthott/laravel-translatable
php artisan make:model YourModel -mtranslatable macro to add translatable fields in your migration. Eg.
Schema::create('dummies', function (Blueprint $table) {
$table->bigIncrements('id');
$table->translatable('user_input');
$table->timestamps();
});
Translatable trait to your newly generated model.translatableFields() method to return an array with a list of your translatable fields to your model.self::translatableRules to gather all the rules you need to assure the correct data format, eg.
{
"en": "English String",
"de": "German String",
}
translatableOptionalFields() method to return an array with the fields as keys and the optional languages as an value as an array.translatable_content, translatable_translations and translatable_languages. The languages table will be filled according to the packages config.To change the default options use
$ php artisan vendor:publish --provider="berthott\Translatable\TranslatableServiceProvider" --tag="config"
namespace: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults to App\Models.namespace_mode: Defines the search mode for the namespaces. ClassFinder::STANDARD_MODE will only find the exact matching namespace, ClassFinder::RECURSIVE_MODE will find all subnamespaces. Defaults to ClassFinder::STANDARD_MODE.languages: Defines the languages used in your application. Defaults to ['en' => 'English']optional_languages: Defines the languages that should be treated optional. Defaults to []default_language: Defines the language that should be used as default. Defaults to enTested with Laravel 10.x.
See License File. Copyright © 2023 Jan Bladt.