This is a package for Laravel to handle localization and requires the package astrotomic/laravel-translatable.
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.
-
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
andmoox/core
package. -
Has Language Switcher Livewire Component and 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
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'])
The LanguageMiddleware is used to set a session cookie for the language.
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.
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"
We are requiring astrotomic/laravel-translatable to use it see doc: https://docs.astrotomic.info/laravel-translatable
Please see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.