Code Monkey home page Code Monkey logo

translation-manager's Introduction

Translation Manager

filament-translation-manager-art

Latest Version on Packagist Total Downloads

Introducing our Filament translation management tool, which allows you to easily manage, preview, and sync translations with your language files all within your Filament admin dashboard. Say goodbye to relying on developers to edit language files and streamline your localization workflow today.

filament-translation-manager-art

Installation

You can install the package via composer:

Install via Composer.

Plugin Version Filament Version PHP Version
<= 3.x 2.x > 8.0
4.x 3.x > 8.1
composer require kenepa/translation-manager

You can run the following command to publish the configuration file:

php artisan vendor:publish --tag=translation-manager-config

This package uses spatie/laravel-translation-loader, publish their migration file using:

php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="migrations"

You have to update the migration file to the following:

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();
});

Finally, run the migration.

Custom Theme Required

In order to compile the package views correctly, we need to create a custom Filament theme first, and then add the following path to its content:

// Located at: /resources/css/filament/admin/tailwind.config.js

import preset from '../../../../vendor/filament/filament/tailwind.config.preset';

export default {
    presets: [preset],
    content: [
        // other content...
        './vendor/kenepa/translation-manager/resources/**/*.blade.php',
    ],
};

Register the plugin with a panel

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

Authorization

By default, the translation manager cannot be used by anyone. You need to define the following gate in your AppServiceProvider boot method:

Gate::define('use-translation-manager', function (?User $user) {
    // Your authorization logic
    return $user !== null && $user->hasRole('admin');
});

Configuration

available_locales

Determines which locales your application supports. For example:

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

language_switcher

Enable or disable the language switcher feature. This allows users to switch their language - disable if you have your own implementation.
Language Switcher

dont_register_navigation_on_panel_ids

Disable registering the translation manager navigation on certain panel IDs. The following will disable the translation navigation for the guest panel but still allow guest panel users to change the language.

    'dont_register_navigation_on_panel_ids' => [
        'guest'
    ],

Usage

Once installed, the Translation Manager can be accessed via the Filament sidebar menu. Simply click on the "Translation Manager" link to access the translation management screen.

License

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

translation-manager's People

Contributors

jehizkia avatar musa11971 avatar daar avatar goodm4ven avatar mansoorkhan96 avatar qalainau avatar musta20 avatar skullbock avatar danoctum avatar lakuapik avatar sinan-aydogan avatar buzkall avatar pardalsalcap avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.