PHP code example of kenepa / translation-manager

1. Go to this page and download the library: Download kenepa/translation-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kenepa / translation-manager example snippets


Schema::create('language_lines', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('group')->index();
    $table->string('key')->index();
    $table->json('text')->default(new \Illuminate\Database\Query\Expression('(JSON_ARRAY())'));
    $table->timestamps();
});

use Kenepa\TranslationManager\TranslationManagerPlugin;
use Filament\Panel;
 
class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(TranslationManagerPlugin::make());
    }
}

use Kenepa\TranslationManager\TranslationManagerPlugin;

TranslationManagerPlugin::make()
    ->availableLocales([
        ['code' => 'en', 'name' => 'English', 'flag' => 'gb'],
        ['code' => 'nl', 'name' => 'Nederlands', 'flag' => 'nl'],
        ['code' => 'fr', 'name' => 'Français', 'flag' => 'fr'],
        ['code' => 'de', 'name' => 'Deutsch', 'flag' => 'de'],
    ])
    ->languageSwitcher(true)
    ->languageSwitcherRenderHook('panels::user-menu.before')
    ->navigationGroup('Settings')
    ->navigationIcon('heroicon-o-globe-alt')
    ->showFlags(true)
    ->disableKeyAndGroupEditing(false)
    ->quickTranslateNavigationRegistration(true)
    ->dontRegisterNavigationOnPanelIds(['guest'])
    ->prependDirectoryPathToGroupName(false)

// app/Providers/AppServiceProvider.php

use Illuminate\Support\Facades\Gate;

/**
 * Bootstrap any application services.
 */
public function boot(): void
{   
    Gate::define('use-translation-manager', function (?User $user) {
        // Your authorization logic
        return $user !== null && $user->hasRole('admin');
    });
}

'available_locales' => [
    ['code' => 'en', 'name' => 'English', 'flag' => 'gb'],
    ['code' => 'nl', 'name' => 'Nederlands', 'flag' => 'nl'],
    ['code' => 'de', 'name' => 'Deutsch', 'flag' => 'de']
]

    'dont_register_navigation_on_panel_ids' => [
        'guest'
    ],

// config/translation-manager.php
[
  // ...Other config   
 'cluster' => \App\Filament\Clusters\Products::class,
]

// In your AdminPanelProvider.php
use Kenepa\TranslationManager\TranslationManagerPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            TranslationManagerPlugin::make()
                ->availableLocales([
                    ['code' => 'en', 'name' => 'English', 'flag' => 'gb'],
                    ['code' => 'nl', 'name' => 'Nederlands', 'flag' => 'nl'],
                    ['code' => 'fr', 'name' => 'Français', 'flag' => 'fr'],
                ])
                ->languageSwitcher(true)
                ->languageSwitcherRenderHook('panels::user-menu.before')
                ->navigationGroup('Settings')
                ->navigationIcon('heroicon-o-globe-alt')
                ->showFlags(true)
                ->disableKeyAndGroupEditing(false)
                ->quickTranslateNavigationRegistration(true)
                ->dontRegisterNavigationOnPanelIds(['guest'])
        );
}
bash
php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-migrations"
php artisan migrate
css
@source '../../../../vendor/kenepa/translation-manager/resources/**/*.blade.php';
bash
php artisan vendor:publish --tag=translation-manager-config
css
@source '../../../../vendor/kenepa/translation-manager/resources/**/*.blade.php';