定制 yeswedev/nova-translatable 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yeswedev/nova-translatable

最新稳定版本:0.9

Composer 安装命令:

composer require yeswedev/nova-translatable

包简介

A Laravel Nova field for astrotomic/laravel-translatable.

README 文档

README

Latest Version on Packagist

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 $translatedAttributes which 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 supports json-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'),

统计信息

  • 总下载量: 100.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 4
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固