bunta/translations
翻译特性
dev-master
2016-08-05 10:26 UTC
This package is auto-updated.
Last update: 2024-09-05 00:20:16 UTC
README
安装
添加到 "\config\app.php"
'providers' => [
...
Bunta\Translations\TranslationsServiceProvider::class
...
],
添加到 "\app\SomeModel.php"
...
use \Bunta\Translations\TranslationsTrait;
...
public $translatedAttributes = ['nameVirtualAttributeToTranslate'];
...
运行命令
composer du
php artisan optimize
php artisan vendor:publish
php artisan migrate
用法
访问正确的翻译
$model->nameVirtualAttributeToTranslate;
访问所有翻译
@foreach(Config::get('translations.locales') as $lang)
{!! Form::text("nameVirtualAttributeToTranslate[$lang]",$model->translation('nameVirtualAttributeToTranslate',$lang)) !!}
@endforeach
保存翻译
Model::create($request->all());