bbs-lab/nova-translation
Composer 安装命令:
composer require bbs-lab/nova-translation
包简介
关键字:
README 文档
README
Contents
Installation
You can install the nova tool in to a Laravel app that uses Nova via composer:
composer require bbs-lab/nova-translation
The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:
'providers' => [ // ... BBSLab\NovaTranslation\NovaTranslationServiceProvider::class, ],
You can tailor default in your application by running:
php artisan vendor:publish --provider="BBSLab\NovaTranslation\NovaTranslationServiceProvider"
You need to run migrations and seeds Locales.
php artisan migrate
Models setup
// @TODO... Explain
-
use Traits\Translatable -
auto_synced_modelsin config.php -
Define
$nonTranslatableattributes (attributes that will be overridden during in all translations during an entry update). -
Define
$onCreateTranslatableattributes (attributes that will be copied during translations entry creation). -
If your using
michielkempen/nova-order-fieldpackage you must override system in model with:
/** * {@inheritdoc} */ public function buildSortQuery() { return static::query()->locale(); }
Configration
You can publish the default configuration by running the following command :
php artisan vendor:publish --provider="BBSLab\NovaTranslation\NovaTranslationServiceProvider"
Using Cookies
By default, the locale is stored in the session upon change, but if you need to access it before the session is started, you can instruct the package to save it in the cookies by enabling it in the config :
'use_cookies' => true,
The cookie will hold the same name defined in locale_session_key
💡 NOTE: The cookie will be encrypted by default, to have it excluded you can add it to your EncryptCookies middleware :
class EncryptCookies extends Middleware { public function __construct(EncrypterContract $encrypter) { parent::__construct($encrypter); $this->except = array_merge($this->except, [ // ... NovaTranslation::localeSessionKey(), ]); } }
Config Nova
Add SetLocale middleware in application kernel.
// app/Http/Kernel.php protected $middleware = [ // ... \BBSLab\NovaTranslation\Http\Middleware\SetLocale::class, ];
Usage
TranslationMatrix tool
You must register the translation matrix backend tool with Nova:
// app/Providers/NovaServiceProvider.php public function tools() { return [ new \BBSLab\NovaTranslation\Tools\TranslationMatrix, ]; }
Nova resource
Nova Resource MUST extends BBSLab\NovaTranslation\Resources\TranslatableResource to work.
Locale resource
And you can add the Locale Nova Resource within your application:
// app/Nova/Locale.php <?php namespace App\Nova; use App\Helpers\StaticLabel; use BBSLab\NovaTranslation\Resources\Locale as BaseResource; class Locale extends BaseResource { /** * {@inheritdoc} */ public static $group = StaticLabel::GROUP_ADMINISTRATION; }
GraphQL
If your using Lighthouse PHP you can add some default Directive and endpoints for Locale and Label.
Directives @allTranslations, @paginateTranslations, @firstTranslation related
Acting as similar @all, @paginate, @first.
You need to add package Directives path to your lighthouse.php configuration file:
// config/lighthouse.php 'namespaces' => [ // ... 'directives' => ['App\\GraphQL\\Directives', 'BBSLab\\NovaTranslation\\GraphQL\\Directives'], ],
Schema
You can include those in your existing schema:
#import ../../../vendor/bbs-lab/nova-translation/src/Http/GraphQL/Locale/*.graphql #import ../../../vendor/bbs-lab/nova-translation/src/Http/GraphQL/Label/*.graphql
Flags resources
Flags UTF-8 (e.g en.json) came from EmojiTerra
TODO
- Add order button on keys heading
- Add search bar to filter keys
- Add checkboxes to enable/disable display of locale
- Add custom message/component when no locale is selected
bbs-lab/nova-translation 适用场景与选型建议
bbs-lab/nova-translation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.69k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「translation」 「nova」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bbs-lab/nova-translation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bbs-lab/nova-translation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bbs-lab/nova-translation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
A custom URL rule class for Yii 2 which allows to create translated URL rules
A Laravel Eloquent model trait for translatable resource
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
统计信息
- 总下载量: 19.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-04