定制 afzaal565/field-translations 二次开发

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

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

afzaal565/field-translations

最新稳定版本:1.0.0

Composer 安装命令:

composer require afzaal565/field-translations

包简介

Laravel package for multilingual field translations via polymorphic relations

README 文档

README

A Laravel package for managing field translations in your database tables using polymorphic relations.

Installation

You can install the package via composer:

composer require afzaal565/field-translations

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="FieldTranslations\Providers\FieldTranslationProvider"

This will create a field-translations.php config file in your config directory.

Usage

1. Add the Trait to Your Model

use FieldTranslations\Traits\HasTranslations;

class YourModel extends Model
{
    use HasTranslations;
    
    protected $translatable = [
        'title',
        'description',
        // Add your translatable fields here
    ];
}

2. Create Translation Tables

Run the migrations:

php artisan migrate

3. Working with Translations

// Set translations
$model->setTranslation('title', 'en', 'English Title');
$model->setTranslation('title', 'es', 'Spanish Title');

// Get translations
$model->getTranslation('title', 'en'); // Returns: English Title
$model->getTranslation('title', 'es'); // Returns: Spanish Title

// Get all translations for a field
$model->getTranslations('title'); // Returns array of all translations

// Check if translation exists
$model->hasTranslation('title', 'en'); // Returns boolean

Features

  • Easy to integrate with any Laravel model
  • Support for multiple languages
  • Automatic translation table creation
  • Flexible configuration options
  • Cache support for better performance

Configuration Options

In your config/field-translations.php file, you can configure:

  • Default language
  • Available languages
  • Cache settings
  • Table naming conventions

Contributing

Please see CONTRIBUTING.md for details.

Security

If you discover any security related issues, please email afzaalhussain565@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-05-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固