承接 moox/localization 相关项目开发

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

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

moox/localization

最新稳定版本:4.0.0-beta.3

Composer 安装命令:

composer require moox/localization

包简介

This is my package localization

README 文档

README

Moox Localization

Moox Localization

This is a package for Laravel to handle localization and requires the package astrotomic/laravel-translatable.

Quick Installation

These two commmands are all you need to install the package:

composer require moox/localization
php artisan localization:install

Curious what the install command does? See manual installation below.

What it does

  • Will create a new table localizations with the following columns:

    • language_id
    • routing_path
    • title
    • description
    • keywords
    • author
    • created_at
    • updated_at
  • Has dependencies to the astrotomic/laravel-translatable and moox/core package.

  • Has Language Switcher Livewire Component and LocalizationPanelProvider.

LocalizationPanelProvider

To use the LocalizationPanelProvider, you need to enable it in the config file:

    'enable-panel' => true,

now the panel will be available at /localization

Language Switcher

Include a Language switcher which wil rely on your created locales. To include it in filament panel

->renderHook(
                \Filament\View\PanelsRenderHook::USER_MENU_BEFORE,
                fn (): string => \Illuminate\Support\Facades\Blade::render('@livewire(\'language-switch\',[\'context\'=>\'backend\'])'),
            );

or just use the livewire component in your blade view:

@livewire('language-switch',['context'=>'backend'])

LanguageMiddleware

The LanguageMiddleware is used to set a session cookie for the language.

Tabs and Translation

Moox Core features like Dynamic Tabs and Translatable Config. See the config file for more details, but as a quick example:

            /*
            |--------------------------------------------------------------------------
            | Tabs
            |--------------------------------------------------------------------------
            |
            | Define the tabs for the Resource table. They are optional, but
            | pretty awesome to filter the table by certain values.
            | You may simply do a 'tabs' => [], to disable them.
            |
            */

            'tabs' => [
                'all' => [
                    'label' => 'trans//core::core.all',
                    'icon' => 'gmdi-filter-list',
                    'query' => [
                        [
                            'field' => 'deleted_at',
                            'operator' => '=',
                            'value' => null,
                        ],
                    ],
                ],
                'published' => [
                    'label' => 'trans//core::core.published',
                    'icon' => 'gmdi-check-circle',
                    'query' => [
                        [
                            'field' => 'publish_at',
                            'operator' => '<=',
                            'value' => function () {
                                return now();
                            },
                        ],
                        [
                            'field' => 'deleted_at',
                            'operator' => '=',
                            'value' => null,
                        ],
                    ],
                ],
                'scheduled' => [
                    'label' => 'trans//core::core.scheduled',
                    'icon' => 'gmdi-schedule',
                    'query' => [
                        [
                            'field' => 'publish_at',
                            'operator' => '>',
                            'value' => function () {
                                return now();
                            },
                        ],
                        [
                            'field' => 'deleted_at',
                            'operator' => '=',
                            'value' => null,
                        ],
                    ],
                ],
                'draft' => [
                    'label' => 'trans//core::core.draft',
                    'icon' => 'gmdi-text-snippet',
                    'query' => [
                        [
                            'field' => 'publish_at',
                            'operator' => '=',
                            'value' => null,
                        ],
                        [
                            'field' => 'deleted_at',
                            'operator' => '=',
                            'value' => null,
                        ],
                    ],
                ],
                'deleted' => [
                    'label' => 'trans//core::core.deleted',
                    'icon' => 'gmdi-delete',
                    'query' => [
                        [
                            'field' => 'deleted_at',
                            'operator' => '!=',
                            'value' => null,
                        ],
                    ],
                ],
            ],
        ],

All options for Tabs are explained in Moox Core docs.

Manual Installation

Instead of using the install-command php artisan localization:install you are able to install this package manually step by step:

// Publish and run the migrations:
php artisan vendor:publish --tag="localization-migrations"
php artisan migrate

// Publish the config file with:
php artisan vendor:publish --tag="localization-config"

use it

We are requiring astrotomic/laravel-translatable to use it see doc: https://docs.astrotomic.info/laravel-translatable

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-07