yeswedev/nova-translatable
Composer 安装命令:
composer require yeswedev/nova-translatable
包简介
A Laravel Nova field for astrotomic/laravel-translatable.
关键字:
README 文档
README
This package is based on mrmonat/nova-translatable.
Adds the ability to show and edit translated fields created with astrotomic/laravel-translatable package.
It will show up in the detail view like this:
And in the edit view like this:
Installation and usage
You can require this package using composer:
composer require yeswedev/nova-translatable
You can add the field follows:
use YesWeDev\Nova\Translatable\Translatable; Translatable::make('Description'),
Make sure, that you have your Eloquent model setup correct:
- First, you need to add the
Astrotomic\Translatable\Translatable-trait. - Next, you should create a public property
$translatedAttributeswhich holds an array with all the names of attributes you wish to make translatable. - Finally, you should make sure that all translatable attributes are set to the
text-datatype in your database. If your database supportsjson-columns, use that.
Here's an example of a prepared model:
use Illuminate\Database\Eloquent\Model; use Astrotomic\Translatable\Translatable; class NewsItem extends Model { use Translatable; public $translatedAttributes = ['name']; }
Defining Locales
Locales can be defined via config file config/translatable.php by adding a locales array:
// config/translatable.php return [ ... 'locales' => [ 'en' => 'English', 'de' => 'German', 'fr' => 'French', ], ];
Alternatively you can "override" the config locales with the locales(...) method:
Translatable::make('Description')->locales([ 'en' => 'English', 'de' => 'German', ]),
Single Line Option
By default the input field on the edit view is a textarea. If you want to change it to a single line input field you can add the singleLine() option:
Translatable::make('Description')->locales([...])->singleLine(),
Trix Editor
You can use the trix editor for your translated fields by using the trix() option:
Translatable::make('Description')->trix(),
Index View
By default the locale used when displaying the field on the index view is determined by app()->getLocale(). To override this you can use the indexLocale($locale) option:
Translatable::make('Description')->indexLocale('de'),
yeswedev/nova-translatable 适用场景与选型建议
yeswedev/nova-translatable 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 103.96k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translatable」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yeswedev/nova-translatable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yeswedev/nova-translatable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yeswedev/nova-translatable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A Laravel Eloquent model trait for translatable resource
An Astrotomic Translatable extension for Laravel Nova.
A Laravel Nova package for publishable fields
Doctrine2 behavior traits - slowhop fork
统计信息
- 总下载量: 103.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-31