statikbe/laravel-nova-chained-translation-manager
Composer 安装命令:
composer require statikbe/laravel-nova-chained-translation-manager
包简介
The Laravel Nova Chained Translation Manager allows you to easily edit and customise the translations of your current Laravel environment.
README 文档
README
Laravel Nova Chained Translation Manager
NOTE: If you are looking for nova 3 check out branch 3.0
The Laravel Nova Chained Translation Manager allows you to easily edit the translations of your current Laravel environment. This translation manager uses the Laravel Chained Translator, that enables you to override the default translations with translations for a specific environment, e.g. a content manager can independently edit and override the translation files on the production environment from the translations provided by the developers.
Typically at some point during the development phase, a content manager wants to translate or finetune the translation strings added by developers. This often results in merge and versioning issues, when developers and content managers are working on the translation files at the same time.
The Chained Translator package allows translations created by developers to exist separately from translations edited by
the content manager in separate lang directories. The library merges the translations of both language directories,
where the translations of the content manager (the custom translations) override those of the developer (the default
translations). Check the documentation of the Laravel Chained Translator
for more info.
Features
- Save translations of the current environment to separate translation files in a separte language directory to avoid version conflicts.
- Immediately save translations
- Search for translations and translation keys
- Filter translations for specific groups and languages
- Only show keys with missing translations
- Support for Nova 4
Currently, this tool does not provide features to add new translation keys, because our target users are translators and content managers and we want to avoid that they add unnecessary translation keys.
Installation
The package can be installed through Composer.
composer require statikbe/laravel-nova-chained-translation-manager
Nova 4 support starts from version v3.0.0. If you are still using Nova 3, please use the v2 version.
composer require statikbe/laravel-nova-chained-translation-manager:~2
Next enable the tool in Nova.
Go to app/Providers/NovaServiceProvider.php and add the TranslationManager to the tools.
use Statikbe\NovaTranslationManager\TranslationManager; public function tools() { return [ new TranslationManager, ]; }
Configuration
You can configure the custom language directory name and extend or finetune the service provider of the Laravel Chained Translator. Have a look at the configuration options of the Laravel Chained Translator library.
Supported locales
There are two ways to change the supported locales.
Option 1
Publish the config file with the command below and configure it with your supported locales and editor preferences.
php artisan vendor:publish --tag=nova-chained-translation-manager
E.g.
/* |-------------------------------------------------------------------------- | Application Supported Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the possible locales that can be used. | You are free to fill this array with any of the locales which will be | supported by the application. | */ 'supported_locales' => [ 'en', 'nl' ],
Option 2
If your application already has a config that declares your locales than you are able to set the supported locales in
any service provider. Create a new one or use the app/Providers/AppServiceProvider.php and set the supported locales
as an array in the boot function as follows:
use Statikbe\NovaTranslationManager\TranslationManager; public function boot() { TranslationManager::setLocales(['en', 'nl']); }
Changing your Editor
Its possible also to change your editor, sometimes the translations values can get big and its good if you have a larger area
to edit them or even add some bold/underline effects on the fly. You can use 3 supported values: input, textarea, trix. Their names are
self-explanatory.
NOTE: We do not recommend Trix as an editor, because if you use variables in your translations within HTML, e.g. for the url of an anchor tag, Trix will remove it :-(. Please, keep in mind while using Trix you should also configure your allowed HTML tags.
Don't forget to clear the cache after changing these settings and refresh your page to see the results :-)
E.g.
/* |-------------------------------------------------------------------------- | Editor to use |-------------------------------------------------------------------------- | | Choose what type of editor you want to use while editing your translations | input - For really dead simple input | textarea - For a larger textarea to deal with | trix - Will use Trix Editor for editing locales supporting some HTML on it. | | Note : Please keep in mind while using Trix to configure your allowed HTML | tags. Otherwise it may pose XSS attacks risk if field could be edited by the end user. | | Values : trix, input, textarea | */ 'editor' => 'input', 'trix_allowed_tags' => '<code><p><b><u><a><br><ul><li><ol><pre><h2><h3><h4><h5><del><blockquote><dl><dd><strong>',
Ignoring Groups
You may also ignore certain groups of translations to be shown in the Nova UI. Create an array with keys that you want to ignore:
E.g.
/* |-------------------------------------------------------------------------- | Ignore Groups |-------------------------------------------------------------------------- | This will ignore certain groups from the translations UI | Supports an array of keys | */ 'ignore_groups' => ['auth','pagination','passwords','routes','nova','nova/validation'],
Merging translations
You can combine the custom translations of the current environment with the default translation files, by running the command provided by the Laravel Chained Translator library package.
Credits
We used Joe Dixon's translation libraries as a source of technical expertise and inspiration:
@nelumoraru and @FrittenKeeZ upgraded the library for Nova 4.
Thanks a lot for the great work!
License
The MIT License (MIT). Please see license file for more information.
Screenshots
statikbe/laravel-nova-chained-translation-manager 适用场景与选型建议
statikbe/laravel-nova-chained-translation-manager 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 30.15k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2020 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「translation」 「nova」 「laravel」 「internationalization」 「chained translator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 statikbe/laravel-nova-chained-translation-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 statikbe/laravel-nova-chained-translation-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 statikbe/laravel-nova-chained-translation-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
Easy to use i18n translation PHP class for multi-language websites
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
统计信息
- 总下载量: 30.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-07



