Skip to content

Latest commit

 

History

History
208 lines (132 loc) · 6.32 KB

README.md

File metadata and controls

208 lines (132 loc) · 6.32 KB

Screenshot of Login

Filament translations

Latest Stable Version PHP Version Require License Downloads

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

Screenshot of list Screenshot of edit Screenshot of settings

Installation

composer require tomatophp/filament-translations

Finally reigster the plugin on /app/Providers/Filament/AdminPanelProvider.php

$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make())

Allow ChatGPT Auto Transaltions

If you want to use ChatGPT to auto-translate your languages, you need to install OpenAI package by running:

composer require openai-php/laravel

now you need to add the following to your .env file:

OPENAI_API_KEY=
OPENAI_ORGANIZATION=

allow the feature on your panel proiver by adding the following:

$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowGPTScan())

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

Publish Resource

You can publish the resource to your project using:

php artisan vendor:publish --tag="filament-translations-migrations"

If you need to publish config run:

php artisan vendor:publish --tag="filament-translations-config"

Run migration:

php artisan migrate

and now clear cache running:

php artisan optimize:clear

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"

Use Language Switcher

You can use the language switcher in your panel by using the following plugin:

$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsSwitcherPlugin::make())

NOTE your auth user table must have lang filed on the table to make this switch working fine.

Usage

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.

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 ,

Other Filament Packages

Support

you can join our discord server to get support TomatoPHP

Docs

you can check docs of this package on Docs

Changelog

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

Security

Please see SECURITY for more information about security.

Credits

License

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