PHP code example of blackbadge-studio / translation-editor
1. Go to this page and download the library: Download blackbadge-studio/translation-editor 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/ */
blackbadge-studio / translation-editor example snippets
use Blackbadgestudio\TranslationEditor\TranslationEditorPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ... other configuration
->plugins([
TranslationEditorPlugin::make(),
// ... other plugins
]);
}
return [
/*
|--------------------------------------------------------------------------
| Model configuration
|--------------------------------------------------------------------------
|
| Configure which Eloquent models / sources are used for translations
| and locales.
|
*/
'models' => [
// The model that represents your translatable strings. This should
// extend Spatie\TranslationLoader\LanguageLine.
'translation' => 'Spatie\\TranslationLoader\\LanguageLine',
// The configuration that represents your locales.
//
// Supported values:
// - an array of locale codes: ['en', 'fr']
// - an array with a model configuration:
// ['model' => App\Models\Locale::class, 'column' => 'code']
// - a model class string that has a `key` (or configured) column.
//
// Example using a locales table:
// 'locale' => [
// 'model' => 'App\\Models\\Locale',
// 'column' => 'code',
// ],
'locale' => [
'en',
'nl',
'fr',
],
],
/*
|--------------------------------------------------------------------------
| Translation loader configuration
|--------------------------------------------------------------------------
|
| Configure how the package integrates with spatie/laravel-translation-loader.
| These values will be applied to the `translation-loader` config at runtime.
| You can override them in your own app config if needed.
|
*/
'translation_loader' => [
// The translation loaders to register with spatie/laravel-translation-loader.
// By default we use the tracking DB loader that works with TranslationTracker.
'translation_loaders' => [
\Blackbadgestudio\TranslationEditor\TranslationLoaders\TrackingDbLoader::class,
],
// The translation manager class which overrides the default Laravel
// `translation.loader`.
'translation_manager' => \Blackbadgestudio\TranslationEditor\TranslationLoaders\TrackingTranslationLoaderManager::class,
],
/*
|--------------------------------------------------------------------------
| Authenticatable model locale column
|--------------------------------------------------------------------------
|
| Configure how the package determines where to store the user's locale.
|
| By default it will use the configured user model and its table:
| config('auth.providers.users.model')
|
| Supported options:
| - 'model': The Authenticatable model class (e.g. App\Models\User::class)
| - 'table': The table name (if you want to override the model's table)
| - 'column': The column name for the locale (defaults to 'locale')
| - 'toggle_column': The column name for enabling/disabling the modal (defaults to 'translation_modal_enabled')
*/
'auth' => [
'model' => 'App\\Models\\User',
'table' => 'users',
'column' => 'locale',
'toggle_column' => 'translation_modal_enabled',
],
];
use Blackbadgestudio\TranslationEditor\Actions\TranslationEditorAction;
use Filament\Resources\Resource;
class UserResource extends Resource
{
// ...
public static function getHeaderActions(): array
{
return [
TranslationEditorAction::make(),
// ... other actions
];
}
}