承接 nathaniel3456/nova-astrotranslatable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nathaniel3456/nova-astrotranslatable

Composer 安装命令:

composer require nathaniel3456/nova-astrotranslatable

包简介

An astrotomic/laravel-translatable extension for Laravel Nova.

README 文档

README

Latest Version on Packagist Total Downloads

This Laravel Nova allows you to make any input field astrotomic/laravel-translatable compatible and localizable.

Requirements

  • PHP: >=8.2
  • laravel/nova: ^5.0
  • astrotomic/laravel-translatable: ^11.10

Version Compatibility

With the release of Nova 5.0, there are now two separate versions of Nova Translatable. Unfortunately due to the nature of the update, the new one isn't backwards compatible. So please choose your version accordingly.

Laravel Nova Nova Translatable
4.0 2.1
5.0 5.0

Features

  • Supports almost all fields (including third party ones)
  • Supports default validation automatically
  • Simple to implement with minimal code changes (after astrotomic/laravel-translatable support)
  • Locale tabs to switch between different locale values of the same field
  • Double-click on a tab to switch all fields to that locale
  • Supports nova-settings package

Known non-working fields

Limitations

  • The following methods can not be used, as this package uses them internally:
    • resolveUsing
    • fillUsing

Screenshots

Form View Detail view
Form View Form view
Form View w/ Validation Errors Form view with validation errors

Installation

Firstly, set up astrotomic/laravel-translatable.

Install the package in a Laravel Nova project via Composer:

# Install nova-astrotranslatable
composer require nathaniel3456/nova-astrotranslatable

# Publish configuration (optional, but useful for setting default locales)
php artisan vendor:publish --tag="nova-translatable-config"

Usage

Call ->translatable() on any field, like so:

// Any Nova field
Text::make('Name')
  ->rules('required', 'min:2')
  ->translatable(),

// Any third-party input field
Multiselect::make('Football teams')
  ->rules('required')
  ->translatable(),

// Optionally pass custom locales on a per-field basis
Number::make('Population')
  ->translatable([
    'en' => 'English',
    'et' => 'Estonian',
  ]),

Validation

It's possible to define locale specific validation rules.

To do so, add the ->rulesFor() on your field and the HandlesTranslatable trait to your Nova resource.

->rulesFor accepts array|string|callable locales and array|callable rules.

use Nathaniel3456\NovaAstrotranslatable\HandlesTranslatable;

class Product extends Resource
{
    use HandlesTranslatable;

    public function fields(Request $request)
    {
        return [
            Text::make(__('Name'), 'name')
                ->sortable()
                ->translatable()
                ->rules(['max:255'])
                ->rulesFor('en', [
                    'required',
                ])
                ->rulesFor(['en', 'et'], function ($locale) {
                    return ["unique:products,name->$locale{{resourceId}}"];
                }),
        ];
    }
}

In this example, rules will be added to the following values

max: name.*
required: name.en
unique: name.en & name.et

Configuration

You can define default locales for all the translatable fields in the config file. The config file can be published using:

php artisan vendor:publish --tag="nova-astrotranslatable-config"

Fill other locales from config option

The configuration option fill_other_locales_from allows you to pre-fill other locales from just one locale. This requires the resources to also have the HandlesTranslatable trait.

One select for all fields on a page

If you don't want to display the locale select next to each field, you can set the display_type to none and add a Nathaniel3456\NovaAstrotranslatable\Fields\LocaleSelect field to your Nova resource. This will render a single select for all fields.

Edge cases

BelongsToMany allowDuplicateRelations corner-case

When using this field inside a BelongsToMany as a pivot field with ->allowDuplicateRelations() and you want to filter out exact matches using the NotExactlyAttached rule, use the BelongsToManyTranslatable field instead of the regular BelongsToMany.

Credits

License

This project is open-sourced software licensed under the MIT license.

nathaniel3456/nova-astrotranslatable 适用场景与选型建议

nathaniel3456/nova-astrotranslatable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「i18n」 「translatable」 「nova」 「laravel」 「translate」 「astrotomic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nathaniel3456/nova-astrotranslatable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nathaniel3456/nova-astrotranslatable 我们能提供哪些服务?
定制开发 / 二次开发

基于 nathaniel3456/nova-astrotranslatable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 64
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-06