tomatophp/filament-translations
Composer 安装命令:
composer require tomatophp/filament-translations
包简介
Manage your translation with DB and cache, you can scan your languages tags like trans(), __(), and get the string inside and translate them use UI.
关键字:
README 文档
README
Filament Translations Manager
Manage your translation with DB and cache, you can scan your languages tags like trans(), __(), and get the string inside and translate them use UI.
this plugin is build in spatie/laravel-translation-loader
Screenshots
Installation
composer require tomatophp/filament-translations
now run install command
php artisan filament-translations:install
Finally register the plugin on /app/Providers/Filament/AdminPanelProvider.php
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make())
Extensions
Allow Create Button to Create New Language
If you want to allow the user to create a new language, you need to add the following to your panel provider:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowCreate())
Allow Clear All Translations Button
If you want to allow the user to clear all translations, you need to add the following to your panel provider:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowClearTranslations())
Use Language Switcher
we move language switcher to another package you can check it Filament Language Switcher
Scan Using Command Line
You can scan your project to get all the languages tags and save them to the database
php artisan filament-translations:import
Change Scan to work on Queue
In your config file just change the use_queue_on_scan to true
'use_queue_on_scan' => true,
Custom Import Command
You can create your own command to import the translations, add your custom import class to the config file like this:
'path_to_custom_import_command' => ImportTranslations::class,
This command will automatically run when you click on the "Scan For New Languages" button in the UI.
Custom Excel Import
You can create your own Excel import to import the translations, add your custom import class to the config file like this:
'path_to_custom_excel_import' => CustomTranslationImport::class,
The import class is based on the Laravel Excel package. You can check the documentation here. This import will automatically run when you click on the "Import" button in the UI.
Custom Excel Export
You can create your own Excel export to export the translations in your own format, add your custom export class to the config file like this:
'path_to_custom_excel_export' => CustomTranslationExport::class,
The export class is based on the Laravel Excel package. You can check the documentation here. This import will automatically run when you click on the "Export" button in the UI.
Show or hide buttons in the UI
You can show or hide the buttons in the UI by changing the config file. By default, all buttons are shown.
'show_import_button' => true, 'show_export_button' => false, 'show_scan_button' => false ,
Custom Resource Nav Label & Group
you can custom your resource nav from config file
'navigation_group' => 'Settings', 'navigation_icon' => 'heroicon-m-language',
Custom Resource
You can create your own resource to show the translations in the UI, add your custom resource class to the config file like this:
'translation_resource' => CustomResource::class,
This is especially useful when you want to have complete control over the UI but still want to use the translations package. Think about implementing a check on user roles when using shouldRegisterNavigation in your custom resource.
Translation Translations Resource Hooks
we have add a lot of hooks to make it easy to attach actions, columns, filters, etc
Table Columns
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Table\TranslationTable; public function boot() { TranslationTable::register([ \Filament\Tables\Columns\TextColumn::make('something') ]); }
Table Actions
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Table\TranslationActions; public function boot() { TranslationActions::register([ \Filament\Tables\Actions\ReplicateAction::make() ]); }
Table Filters
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Table\TranslationFilters; public function boot() { TranslationFilters::register([ \Filament\Tables\Filters\SelectFilter::make('something') ]); }
Table Bulk Actions
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Table\TranslationBulkActions; public function boot() { TranslationBulkActions::register([ \Filament\Tables\BulkActions\DeleteAction::make() ]); }
From Components
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Form\TranslationForm; public function boot() { TranslationForm::register([ \Filament\Forms\Components\TextInput::make('something') ]); }
Page Actions
use TomatoPHP\FilamentTranslations\Filament\Resources\Translations\Pages\ManageTranslation; use TomatoPHP\FilamentTranslations\Facade\FilamentTranslations; public function boot() { FilamentTranslations::register(Action::make(), ManageTranslation::class) }
Publish Assets
You can publish views file by use this command:
php artisan vendor:publish --tag="filament-translations-views"
You can publish languages file by use this command:
php artisan vendor:publish --tag="filament-translations-lang"
You can publish migrations file by use this command:
php artisan vendor:publish --tag="filament-translations-migrations"
Testing
if you like to run PEST testing just use this command
composer test
Code Style
if you like to fix the code style just use this command
composer format
PHPStan
if you like to check the code by PHPStan just use this command
composer analyse
Other Filament Packages
Checkout our Awesome TomatoPHP
tomatophp/filament-translations 适用场景与选型建议
tomatophp/filament-translations 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34.69k 次下载、GitHub Stars 达 62, 最近一次更新时间为 2023 年 09 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「php」 「db」 「translations」 「language」 「loader」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tomatophp/filament-translations 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tomatophp/filament-translations 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tomatophp/filament-translations 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Deepl Automated translations for Laravel lang files
A PSR-7 compatible library for making CRUD API endpoints
Adds support for dynamic translations from Google Spreadsheets.
统计信息
- 总下载量: 34.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 62
- 点击次数: 35
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-28





