diff --git a/convert_translations.php b/convert_translations.php new file mode 100644 index 0000000..61259cb --- /dev/null +++ b/convert_translations.php @@ -0,0 +1,81 @@ +isDir()) { + continue; + } + + // Check if the file is a PHP or STUB file + $fileExtension = $file->getExtension(); + if ($fileExtension === 'php' || $fileExtension === 'stub') { + processFile($file->getPathname(), $messages); + } + } +} + +// This function processes each PHP file to find and convert __() strings +function processFile($filePath, &$messages) +{ + $content = file_get_contents($filePath); + // Updated regex to exclude __() calls that contain 'Str::' after the opening __(' + preg_match_all("/__\(\s*['\"](?!.*Str::)(.*?)['\"]\s*\)/", $content, $matches, PREG_SET_ORDER); + + foreach ($matches as $match) { + $originalString = $match[1]; // The original string inside __() + // Check if the string contains '{{' and '}}', indicating a variable + if (strpos($originalString, '{{') !== false && strpos($originalString, '}}') !== false) { + continue; // Skip processing this match + } + $key = generateTransKey($originalString); // Generate a key for the trans() function + $messages['plugins'][$key] = $originalString; + + // Prepare the replacement string + $replacement = "trans('filament-plugins::messages.plugins.$key')"; + // Use preg_replace to replace only the first occurrence + $pattern = '/' . preg_quote($match[0], '/') . '/'; + $content = preg_replace($pattern, $replacement, $content, 1); + } + + // Write the modified content back to the file + file_put_contents($filePath, $content); +} + +function generateTransKey($string) +{ + // Handle the case where the string contains variable placeholders + if (strpos($string, '{{') !== false && strpos($string, '}}') !== false) { + return $string; // Return the string as is, assuming it's a variable + } + + // Convert the string to a slug-like format + $key = strtolower(preg_replace('/[^a-zA-Z0-9]+/', '_', $string)); + + // Trim trailing underscores + $key = rtrim($key, '_'); + + return $key; +} + +// This function saves the messages array to a PHP file +function saveMessagesToFile($messages, $filePath) +{ + $export = var_export($messages, true); + $content = " + [ + 'save' => 'Save', + 'delete' => 'Delete', + 'cancel' => 'Cancel', + 'edit' => 'Edit', + 'updated_successfully' => 'updated successfully', + 'deleted_successfully' => 'deleted successfully', + 'create' => 'Create', + 'has_been_deleted' => 'Has Been Deleted', + 'add_column' => 'Add Column', + 'add_id' => 'Add Id', + 'add_timestamps' => 'Add Timestamps', + 'add_soft_deletes' => 'Add Soft Deletes', + 'create_table' => 'Create Table', + 'migrate' => 'Migrate', + 'migrated' => 'Migrated', + 'table_migrated_successfully' => 'Table migrated successfully.', + 'generate' => 'Generate', + 'error' => 'Error', + 'docs' => 'Docs', + 'table_does_not_exist_please_run_migrate' => 'Table does not exist please run migrate.', + 'model_does_not_exist_please_generate_model_first' => 'Model does not exist please generate model first.', + 'generated' => 'Generated', + 'table_generated_successfully' => 'Table generated successfully.', + 'plugins' => 'Plugins', + 'settings' => 'Settings', + 'disable' => 'Disable', + 'plugin_disabled' => 'Plugin Disabled', + 'the_plugin_has_been_disabled_successfully' => 'The plugin has been disabled successfully.', + 'plugin_deleted' => 'Plugin Deleted', + 'the_plugin_has_been_deleted_successfully' => 'The plugin has been deleted successfully.', + 'active' => 'Active', + 'you_need_to_run_autoload' => 'You need to run autoload', + 'you_need_to_run_composer_dump_autoload_before_activating_the_plugin' => 'You need to run composer dump-autoload before activating the plugin.', + 'plugin_enabled' => 'Plugin Enabled', + 'the_plugin_has_been_enabled_successfully' => 'The plugin has been enabled successfully.', + 'create_plugin' => 'Create Plugin', + 'plugin_name' => 'Plugin Name', + 'e_g_my_plugin' => 'e.g. My Plugin', + 'description' => 'Description', + 'e_g_a_simple_plugin_for_filament' => 'e.g. A simple plugin for Filament', + 'import_plugin' => 'Import Plugin', + 'plugin_file' => 'Plugin File', + 'plugin_uploaded' => 'Plugin Uploaded', + 'the_plugin_has_been_uploaded_successfully' => 'The plugin has been uploaded successfully.', + 'plugin_already_exists' => 'Plugin Already Exists', + 'the_plugin_you_are_trying_to_create_already_exists' => 'The plugin you are trying to create already exists.', + 'plugin_generated_success' => 'Plugin Generated Success', + 'the_plugin_has_been_generated_successfully' => 'The plugin has been generated successfully.', + ], +]; diff --git a/resources/lang/ar.json b/resources/lang/ar.json deleted file mode 100644 index 0db3279..0000000 --- a/resources/lang/ar.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/resources/lang/ar/messages.php b/resources/lang/ar/messages.php index ca5d8ed..c082fef 100644 --- a/resources/lang/ar/messages.php +++ b/resources/lang/ar/messages.php @@ -1,5 +1,102 @@ 'الإعدادات', + 'plugins' => [ + 'title' => 'الاضافات', + 'create' => 'إنشاء اضافة جديدة', + 'import' => 'استيراد اضافة', + 'form' => [ + 'name' => 'الاسم', + 'name-placeholder' => 'e.g. My Plugin', + 'description' => 'الوصف', + 'description-placeholder' => 'e.g. A simple plugin for Filament', + 'icon' => 'الايقونة', + 'color' => 'اللون', + 'file' => 'ملف الاضافة المضغوط', + ], + 'actions' => [ + 'generate' => 'توليد', + 'active' => 'تفعيل', + 'disable' => 'إبطال', + 'delete' => 'حذف', + 'github' => 'جيت هاب', + 'docs' => 'عن الاضافة', + ], + 'notifications' => [ + 'autoload' => [ + 'title' => 'خطأ', + 'body' => 'عفواً لا يمكن تفعيل هذه الاضافة قبل تشغيل الامر composer dump-autoload في الطرفية' + ], + 'enabled' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم تفعيل الاضافة بنجاح' + ], + 'deleted' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم حذف الاضافة بنجاح' + ], + 'disabled' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم تبطيل الاضافة بنجاح' + ], + 'import' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم استيراد الاضافة بنجاح' + ] + ] + ], + 'tables' => [ + 'title' => 'الجداول', + 'create' => 'إنشاء جدول جديد', + 'edit' => 'تعديل الجدول', + 'columns' => 'أعمدة الجدول', + 'form' => [ + 'name' => 'الاسم', + 'type' => 'النوع', + 'nullable' => 'يمكن أن يكون فارغاً', + 'foreign' => 'خارجي', + 'foreign_table' => 'جدول خارجي', + 'foreign_col' => 'عمود خارجي', + 'foreign_on_delete_cascade' => 'عند الحذف يتبع', + 'auto_increment' => 'تزايد تلقائياً', + 'primary' => 'رئيسي', + 'unsigned' => 'غير سالب', + 'default' => 'افتراضي', + 'unique' => 'فريد', + 'index' => 'فهرس', + 'lenth' => 'الطول', + 'migrated' => 'تم التهجير', + 'generated' => 'تم التوليد', + 'created_at' => 'تاريخ الإنشاء', + 'updated_at' => 'تاريخ التحديث', + ], + 'actions' => [ + 'create' => 'إنشاء جدول', + 'migrate' => 'تهجير', + 'generate' => 'توليد', + 'columns' => 'اضافة عمود', + 'add-id' => 'إضافة عمود ID', + 'add-timestamps' => 'إضافة الوقت', + 'add-softdeletes' => 'إضافة حذف ناعم', + ], + 'notifications' => [ + 'migrated' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم تهجير الجدول بنجاح' + ], + 'not-migrated' => [ + 'title' => 'خطأ', + 'body' => 'لا يمكن تهجير الجدول' + ], + 'generated' => [ + 'title' => 'عملية ناجحة', + 'body' => 'تم توليد الجدول بنجاح' + ], + 'model' => [ + 'title' => 'خطأ', + 'body' => 'لا يمكن توليد النموذج' + ] + ] + ] ]; diff --git a/resources/lang/en.json b/resources/lang/en.json deleted file mode 100644 index 0db3279..0000000 --- a/resources/lang/en.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index ca5d8ed..ae6bfc7 100644 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -1,5 +1,102 @@ 'Settings', + 'plugins' => [ + 'title' => 'Plugins', + 'create' => 'Create Plugin', + 'import' => 'Import Plugin', + 'form' => [ + 'name' => 'Name', + 'name-placeholder' => 'e.g. My Plugin', + 'description' => 'Description', + 'description-placeholder' => 'e.g. A simple plugin for Filament', + 'icon' => 'Icon', + 'color' => 'Color', + 'file' => 'Plugin ZIP file', + ], + 'actions' => [ + 'generate' => 'Generate', + 'active' => 'Active', + 'disable' => 'Disable', + 'delete' => 'Delete', + 'github' => 'Github', + 'docs' => 'Docs', + ], + 'notifications' => [ + 'autoload' => [ + 'title' => 'Error', + 'body' => 'The plugin could not be activated because the class could not be found. please run composer dump-autoload on your terminal' + ], + 'enabled' => [ + 'title' => 'Success', + 'body' => 'The plugin has been activated successfully.' + ], + 'deleted' => [ + 'title' => 'Success', + 'body' => 'The plugin has been deleted successfully.' + ], + 'disabled' => [ + 'title' => 'Success', + 'body' => 'The plugin has been deactivated successfully.' + ], + 'import' => [ + 'title' => 'Success', + 'body' => 'The plugin has been imported successfully.' + ] + ] + ], + 'tables' => [ + 'title' => 'Tables', + 'create' => 'Create Table', + 'edit' => 'Edit Table', + 'columns' => 'Table Columns', + 'form' => [ + 'name' => 'Name', + 'type' => 'Type', + 'nullable' => 'Nullable', + 'foreign' => 'Foreign', + 'foreign_table' => 'Foreign Table', + 'foreign_col' => 'Foreign Column', + 'foreign_on_delete_cascade' => 'On Delete Cascade', + 'auto_increment' => 'Auto Increment', + 'primary' => 'Primary', + 'unsigned' => 'Unsigned', + 'default' => 'Default', + 'unique' => 'Unique', + 'index' => 'Index', + 'lenth' => 'Length', + 'migrated' => 'Migrated', + 'generated' => 'Generated', + 'created_at' => 'Created At', + 'updated_at' => 'Update At', + ], + 'actions' => [ + 'create' => 'Create Table', + 'migrate' => 'Migrate', + 'generate' => 'Generate', + 'columns' => 'Add Column', + 'add-id' => 'Add ID Column', + 'add-timestamps' => 'Add Timestamps', + 'add-softdeletes' => 'Add Soft Deletes', + ], + 'notifications' => [ + 'migrated' => [ + 'title' => 'Success', + 'body' => 'The table has been migrated successfully.' + ], + 'not-migrated' => [ + 'title' => 'Error', + 'body' => 'The table could not be migrated.' + ], + 'generated' => [ + 'title' => 'Success', + 'body' => 'The table has been generated successfully.' + ], + 'model' => [ + 'title' => 'Error', + 'body' => 'The model could not be found generate it first.' + ] + ] + ] ]; diff --git a/resources/lang/nl/messages.php b/resources/lang/nl/messages.php new file mode 100644 index 0000000..856d988 --- /dev/null +++ b/resources/lang/nl/messages.php @@ -0,0 +1,102 @@ + 'Settings', + 'plugins' => [ + 'title' => 'Plugins', + 'create' => 'Create Plugin', + 'import' => 'Import Plugin', + 'form' => [ + 'name' => 'Name', + 'name-placeholder' => 'e.g. My Plugin', + 'description' => 'Description', + 'description-placeholder' => 'e.g. A simple plugin for Filament', + 'icon' => 'Icon', + 'color' => 'Color', + 'file' => 'Plugin ZIP file', + ], + 'actions' => [ + 'generate' => 'Generate', + 'active' => 'Active', + 'disable' => 'Disable', + 'delete' => 'Delete', + 'github' => 'Github', + 'docs' => 'Docs', + ], + 'notifications' => [ + 'autoload' => [ + 'title' => 'Error', + 'body' => 'The plugin could not be activated because the class could not be found. please run composer dump-autoload on your terminal' + ], + 'enabled' => [ + 'title' => 'Success', + 'body' => 'The plugin has been activated successfully.' + ], + 'deleted' => [ + 'title' => 'Success', + 'body' => 'The plugin has been deleted successfully.' + ], + 'disabled' => [ + 'title' => 'Success', + 'body' => 'The plugin has been deactivated successfully.' + ], + 'import' => [ + 'title' => 'Success', + 'body' => 'The plugin has been imported successfully.' + ] + ] + ], + 'tables' => [ + 'title' => 'Tables', + 'create' => 'Create Table', + 'edit' => 'Edit Table', + 'columns' => 'Table Columns', + 'form' => [ + 'name' => 'Name', + 'type' => 'Type', + 'nullable' => 'Nullable', + 'foreign' => 'Foreign', + 'foreign_table' => 'Foreign Table', + 'foreign_col' => 'Foreign Column', + 'foreign_on_delete_cascade' => 'On Delete Cascade', + 'auto_increment' => 'Auto Increment', + 'primary' => 'Primary', + 'unsigned' => 'Unsigned', + 'default' => 'Default', + 'unique' => 'Unique', + 'index' => 'Index', + 'lenth' => 'Length', + 'migrated' => 'Migrated', + 'generated' => 'Generated', + 'created_at' => 'Created At', + 'updated_at' => 'Update At', + ], + 'actions' => [ + 'create' => 'Create Table', + 'migrate' => 'Migrate', + 'generate' => 'Generate', + 'columns' => 'Add Column', + 'add-id' => 'Add ID Column', + 'add-timestamps' => 'Add Timestamps', + 'add-softdeletes' => 'Add Soft Deletes', + ], + 'notifications' => [ + 'migrated' => [ + 'title' => 'Success', + 'body' => 'The table has been migrated successfully.' + ], + 'not-migrated' => [ + 'title' => 'Error', + 'body' => 'The table could not be migrated.' + ], + 'generated' => [ + 'title' => 'Success', + 'body' => 'The table has been generated successfully.' + ], + 'model' => [ + 'title' => 'Error', + 'body' => 'The model could not be found generate it first.' + ] + ] + ] +]; diff --git a/resources/views/pages/table.blade.php b/resources/views/pages/table.blade.php index 0e04503..6bbfeef 100644 --- a/resources/views/pages/table.blade.php +++ b/resources/views/pages/table.blade.php @@ -30,7 +30,7 @@
@if($item['type'] !== 'lib') @if((bool)config('filament-plugins.allow_generator')) - + @@ -51,14 +51,14 @@
@if($item->github) - + @endif @if($item->docs) - + diff --git a/src/Pages/Plugins.php b/src/Pages/Plugins.php index d23521e..26d4c65 100644 --- a/src/Pages/Plugins.php +++ b/src/Pages/Plugins.php @@ -32,12 +32,21 @@ class Plugins extends Page implements HasTable protected $listeners = ['pluginRefresh' => '$refresh']; public static ?string $navigationIcon = 'heroicon-o-squares-plus'; - public static ?string $navigationGroup = 'Settings'; public static string $view = 'filament-plugins::pages.plugins'; public function getTitle(): string { - return 'Plugins'; + return trans('filament-plugins::messages.plugins.title'); + } + + public static function getNavigationLabel(): string + { + return trans('filament-plugins::messages.plugins.title'); + } + + public static function getNavigationGroup(): ?string + { + return trans('filament-plugins::messages.group'); } public function table(Table $table): Table @@ -48,7 +57,9 @@ public function table(Table $table): Table return view('filament-plugins::pages.table'); }) ->columns([ - TextColumn::make('name')->searchable(), + TextColumn::make('name') + ->label(trans('filament-plugins::messages.plugins.form.name')) + ->searchable(), ]); } @@ -58,15 +69,15 @@ public function disableAction(): Action ->iconButton() ->icon('heroicon-s-x-circle') ->color('danger') - ->tooltip('Disable') + ->tooltip(trans('filament-plugins::messages.plugins.actions.disable')) ->requiresConfirmation() ->action(function (array $arguments) { $module = Module::find($arguments['item']['module_name']); $module?->disable(); Notification::make() - ->title(__("Plugin Disabled")) - ->body(__("The plugin has been disabled successfully.")) + ->title(trans('filament-plugins::messages.plugins.notifications.disabled.title')) + ->body(trans('filament-plugins::messages.plugins.notifications.disabled.body')) ->success() ->send(); @@ -80,15 +91,15 @@ public function deleteAction(): Action ->iconButton() ->icon('heroicon-s-trash') ->color('danger') - ->tooltip('Delete') + ->tooltip(trans('filament-plugins::messages.plugins.actions.delete')) ->requiresConfirmation() ->action(function (array $arguments) { $module = Module::find($arguments['item']['module_name']); $module?->delete(); Notification::make() - ->title(__("Plugin Deleted")) - ->body(__("The plugin has been deleted successfully.")) + ->title(trans('filament-plugins::messages.plugins.notifications.deleted.title')) + ->body(trans('filament-plugins::messages.plugins.notifications.deleted.body')) ->success() ->send(); @@ -102,14 +113,14 @@ public function activeAction(): Action return Action::make('active') ->iconButton() ->icon('heroicon-s-check-circle') - ->tooltip('Active') + ->tooltip(trans('filament-plugins::messages.plugins.actions.active')) ->color('success') ->requiresConfirmation() ->action(function (array $arguments) { if(!class_exists(json_decode($arguments['item']['providers'])[0])){ Notification::make() - ->title(__("You need to run autoload")) - ->body(__("You need to run composer dump-autoload before activating the plugin.")) + ->title(trans('filament-plugins::messages.plugins.notifications.autoload.title')) + ->body(trans('filament-plugins::messages.plugins.notifications.autoload.body')) ->danger() ->send(); return; @@ -118,8 +129,8 @@ public function activeAction(): Action $module?->enable(); Notification::make() - ->title(__("Plugin Enabled")) - ->body(__("The plugin has been enabled successfully.")) + ->title(trans('filament-plugins::messages.plugins.notifications.enabled.title')) + ->body(trans('filament-plugins::messages.plugins.notifications.enabled.body')) ->success() ->send(); @@ -133,27 +144,31 @@ public function getHeaderActions(): array if((bool)config('filament-plugins.allow_create')){ return [ Action::make('create') - ->label('Create Plugin') + ->label(trans('filament-plugins::messages.plugins.create')) ->icon('heroicon-o-plus') ->form([ TextInput::make('name') - ->label('Plugin Name') - ->placeholder('e.g. My Plugin') + ->label(trans('filament-plugins::messages.plugins.form.name')) + ->placeholder(trans('filament-plugins::messages.plugins.form.name-placeholder')) ->required(), Textarea::make('description') - ->label('Description') - ->placeholder('e.g. A simple plugin for Filament') + ->label(trans('filament-plugins::messages.plugins.form.description')) + ->placeholder(trans('filament-plugins::messages.plugins.form.description-placeholder')) + ->required(), + ColorPicker::make('color') + ->label(trans('filament-plugins::messages.plugins.form.color')) ->required(), - ColorPicker::make('color')->required(), - IconPicker::make('icon')->required() + IconPicker::make('icon') + ->label(trans('filament-plugins::messages.plugins.form.icon')) + ->required() ]) ->action(fn (array $data) => $this->createPlugin($data)), Action::make('import') - ->label('Import Plugin') + ->label(trans('filament-plugins::messages.plugins.import')) ->icon('heroicon-o-arrow-up-on-square') ->form([ FileUpload::make('file') - ->label('Plugin File') + ->label(trans('filament-plugins::messages.plugins.form.file')) ->acceptedFileTypes(['application/zip']) ->required() ->storeFiles(false) @@ -180,8 +195,8 @@ public function importPlugin(array $data) $zip->close(); Notification::make() - ->title(__("Plugin Uploaded")) - ->body(__("The plugin has been uploaded successfully.")) + ->title(trans('filament-plugins::messages.plugins.notifications.import.title')) + ->body(trans('filament-plugins::messages.plugins.notifications.import.body')) ->success() ->send(); @@ -195,8 +210,8 @@ public function createPlugin(array $data) $checkIfPluginExists = Module::find(Str::of($data['name'])->camel()->ucfirst()->toString()); if($checkIfPluginExists){ Notification::make() - ->title(__("Plugin Already Exists")) - ->body(__("The plugin you are trying to create already exists.")) + ->title(trans('filament-plugins::messages.plugins.notification.exists.title')) + ->body(trans('filament-plugins::messages.plugins.notification.exists.body')) ->danger() ->send(); } @@ -210,8 +225,8 @@ public function createPlugin(array $data) $generator->generate(); Notification::make() - ->title(__("Plugin Generated Success")) - ->body(__("The plugin has been generated successfully.")) + ->title(trans('filament-plugins::messages.plugins.notification.imported.title')) + ->body(trans('filament-plugins::messages.plugins.notification.imported.body')) ->success() ->send(); } diff --git a/src/Resources/TableResource.php b/src/Resources/TableResource.php index 0aed529..c298ac0 100644 --- a/src/Resources/TableResource.php +++ b/src/Resources/TableResource.php @@ -32,6 +32,7 @@ public static function form(Form $form): Form return $form ->schema([ Forms\Components\TextInput::make('name') + ->label(trans('filament-plugins::messages.tables.form.name')) ->columnSpan(2) ->required() ->maxLength(255), @@ -51,16 +52,21 @@ public static function table(Table $table): Table ->query($query) ->columns([ Tables\Columns\TextColumn::make('name') + ->label(trans('filament-plugins::messages.tables.form.name')) ->searchable(), Tables\Columns\IconColumn::make('migrated') + ->label(trans('filament-plugins::messages.tables.form.migrated')) ->boolean(), Tables\Columns\IconColumn::make('generated') + ->label(trans('filament-plugins::messages.tables.form.generated')) ->boolean(), Tables\Columns\TextColumn::make('created_at') + ->label(trans('filament-plugins::messages.tables.form.created_at')) ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') + ->label(trans('filament-plugins::messages.tables.form.updated_at')) ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), @@ -69,24 +75,26 @@ public static function table(Table $table): Table // ]) ->actions([ - Tables\Actions\EditAction::make()->iconButton(), - Tables\Actions\DeleteAction::make()->iconButton(), + Tables\Actions\EditAction::make() + ->iconButton(), + Tables\Actions\DeleteAction::make() + ->iconButton(), Tables\Actions\Action::make('migrate') ->requiresConfirmation() - ->tooltip('Migrate') + ->tooltip(trans('filament-plugins::messages.tables.actions.migrate')) ->color('info') ->iconButton() ->icon('heroicon-s-circle-stack') ->action(function (TableModel $record){ $record->migrate(); Notification::make() - ->title('Migrated') - ->body('Table migrated successfully.') + ->title(trans('filament-plugins::messages.tables.notifications.migrated.title')) + ->body(trans('filament-plugins::messages.tables.notifications.migrated.body')) ->success() ->send(); }), Tables\Actions\Action::make('generate') - ->tooltip('Generate') + ->tooltip(trans('filament-plugins::messages.tables.actions.generate')) ->color('info') ->iconButton() ->icon('heroicon-s-home-modern') @@ -111,8 +119,8 @@ public static function table(Table $table): Table ->action(function (TableModel $record, array $data){ if((!Schema::hasTable($record->name)) && $data['type'] !== 'migrate'){ Notification::make() - ->title('Error') - ->body('Table does not exist please run migrate.') + ->title(trans('filament-plugins::messages.tables.notifications.not-migrated.title')) + ->body(trans('filament-plugins::messages.tables.notifications.not-migrated.body')) ->danger() ->send(); return; @@ -126,8 +134,8 @@ public static function table(Table $table): Table sleep(1); Notification::make() - ->title('Migrated') - ->body('Table migrated successfully.') + ->title(trans('filament-plugins::messages.tables.notifications.migrated.title')) + ->body(trans('filament-plugins::messages.tables.notifications.migrated.body')) ->success() ->send(); return; @@ -138,8 +146,8 @@ public static function table(Table $table): Table if((!$checkIfModelExists) && in_array($data['type'], ['resource', 'page', 'widget'])){ Notification::make() - ->title('Error') - ->body('Model does not exist please generate model first.') + ->title(trans('filament-plugins::messages.tables.notifications.model.title')) + ->body(trans('filament-plugins::messages.tables.notifications.model.body')) ->danger() ->send(); return; @@ -180,8 +188,8 @@ public static function table(Table $table): Table $generator->generate(); Notification::make() - ->title('Generated') - ->body('Table generated successfully.') + ->title(trans('filament-plugins::messages.tables.notifications.generated.title')) + ->body(trans('filament-plugins::messages.tables.notifications.generated.body')) ->success() ->send(); }), diff --git a/src/Resources/TableResource/Pages/CreateTable.php b/src/Resources/TableResource/Pages/CreateTable.php index c9da573..998a9ef 100644 --- a/src/Resources/TableResource/Pages/CreateTable.php +++ b/src/Resources/TableResource/Pages/CreateTable.php @@ -10,6 +10,11 @@ class CreateTable extends CreateRecord { protected static string $resource = TableResource::class; + public function getTitle(): string + { + return trans('filament-plugins::messages.tables.create'); + } + public ?string $module = null; public function mount(): void diff --git a/src/Resources/TableResource/Pages/EditTable.php b/src/Resources/TableResource/Pages/EditTable.php index ce0d50b..8cf0969 100644 --- a/src/Resources/TableResource/Pages/EditTable.php +++ b/src/Resources/TableResource/Pages/EditTable.php @@ -10,6 +10,11 @@ class EditTable extends EditRecord { protected static string $resource = TableResource::class; + public function getTitle(): string + { + return trans('filament-plugins::messages.tables.edit'); + } + protected function getHeaderActions(): array { return [ diff --git a/src/Resources/TableResource/Pages/ListTables.php b/src/Resources/TableResource/Pages/ListTables.php index 78d9aff..f343412 100644 --- a/src/Resources/TableResource/Pages/ListTables.php +++ b/src/Resources/TableResource/Pages/ListTables.php @@ -10,12 +10,16 @@ class ListTables extends ListRecords { protected static string $resource = TableResource::class; + public function getTitle(): string + { + return trans('filament-plugins::messages.tables.title'); + } protected function getHeaderActions(): array { return [ Actions\Action::make('create') - ->label('Create Table') + ->label(trans('filament-plugins::messages.tables.actions.create')) ->url(route('filament.'.filament()->getCurrentPanel()->getId().'.resources.tables.create', ['module' => request()->get('module')])) ]; } diff --git a/src/Resources/TableResource/RelationManagers/TableColsRelationManager.php b/src/Resources/TableResource/RelationManagers/TableColsRelationManager.php index 060dac1..4b2352d 100644 --- a/src/Resources/TableResource/RelationManagers/TableColsRelationManager.php +++ b/src/Resources/TableResource/RelationManagers/TableColsRelationManager.php @@ -20,7 +20,7 @@ class TableColsRelationManager extends RelationManager public static function getTitle(Model $ownerRecord, string $pageClass): string { - return 'Table Columns'; + return trans('filament-plugins::messages.tables.columns'); } public function form(Form $form): Form @@ -28,9 +28,11 @@ public function form(Form $form): Form return $form ->schema([ Forms\Components\TextInput::make('name') + ->label(trans('filament-plugins::messages.tables.form.name')) ->required() ->maxLength(255), Forms\Components\Select::make('type') + ->label(trans('filament-plugins::messages.tables.form.type')) ->searchable() ->required() ->default('string') @@ -53,40 +55,50 @@ public function form(Form $form): Form 'timestamps' => 'timestamps', ]), Forms\Components\TextInput::make('length') + ->label(trans('filament-plugins::messages.tables.form.lenth')) ->default(255) ->maxLength(255), Forms\Components\TextInput::make('default') ->maxLength(255), - Forms\Components\Toggle::make('nullable')->default(true), - Forms\Components\Toggle::make('unsigned'), - Forms\Components\Toggle::make('auto_increment'), - Forms\Components\Toggle::make('primary'), - Forms\Components\Toggle::make('unique'), - Forms\Components\Toggle::make('index'), + Forms\Components\Toggle::make('nullable') + ->label(trans('filament-plugins::messages.tables.form.nullable')) + ->default(true), + Forms\Components\Toggle::make('unsigned') + ->label(trans('filament-plugins::messages.tables.form.unsigned')), + Forms\Components\Toggle::make('auto_increment') + ->label(trans('filament-plugins::messages.tables.form.auto_increment')), + Forms\Components\Toggle::make('primary') + ->label(trans('filament-plugins::messages.tables.form.primary')), + Forms\Components\Toggle::make('unique') + ->label(trans('filament-plugins::messages.tables.form.unique')), + Forms\Components\Toggle::make('index') + ->label(trans('filament-plugins::messages.tables.form.index')), Forms\Components\Toggle::make('foreign') - ->afterStateUpdated(function(Forms\Set $set, Forms\Get $get) { - if($get('foreign') === true) { + ->label(trans('filament-plugins::messages.tables.form.foreign')) + ->afterStateUpdated(function (Forms\Set $set, Forms\Get $get) { + if ($get('foreign') === true) { $set('type', 'bigint'); $set('unsigned', true); - } - else { + } else { $set('type', null); $set('unsigned', false); } - }) ->live(), Forms\Components\TextInput::make('foreign_table') + ->label(trans('filament-plugins::messages.tables.form.foreign_table')) ->required() ->columnSpan(2) - ->hidden(fn(Forms\Get $get) => !$get('foreign')), + ->hidden(fn (Forms\Get $get) => !$get('foreign')), Forms\Components\TextInput::make('foreign_col') + ->label(trans('filament-plugins::messages.tables.form.foreign_col')) ->required() ->columnSpan(2) - ->hidden(fn(Forms\Get $get) => !$get('foreign')), + ->hidden(fn (Forms\Get $get) => !$get('foreign')), Forms\Components\Toggle::make('foreign_on_delete_cascade') + ->label(trans('filament-plugins::messages.tables.form.foreign_on_delete_cascade')) ->required() - ->hidden(fn(Forms\Get $get) => !$get('foreign')), + ->hidden(fn (Forms\Get $get) => !$get('foreign')), ]); } @@ -96,12 +108,16 @@ public function table(Table $table): Table ->reorderable('id') ->recordTitleAttribute('name') ->columns([ - Tables\Columns\TextColumn::make('name'), - Tables\Columns\TextColumn::make('type'), - Tables\Columns\BooleanColumn::make('nullable'), + Tables\Columns\TextColumn::make('name') + ->label(trans('filament-plugins::messages.tables.form.name')), + Tables\Columns\TextColumn::make('type') + ->label(trans('filament-plugins::messages.tables.form.type')), + Tables\Columns\BooleanColumn::make('nullable') + ->label(trans('filament-plugins::messages.tables.form.nullable')), ]) ->filters([ Tables\Filters\SelectFilter::make('type') + ->label(trans('filament-plugins::messages.tables.form.type')) ->searchable() ->options([ 'int' => 'int', @@ -123,16 +139,15 @@ public function table(Table $table): Table ]), ]) ->headerActions([ - Tables\Actions\CreateAction::make() - ->label('Add Column'), + ->label(trans('filament-plugins::messages.tables.actions.columns')), Tables\Actions\ActionGroup::make([ Tables\Actions\Action::make('id') ->color('info') ->requiresConfirmation() - ->label('Add Id') + ->label(trans('filament-plugins::messages.tables.actions.add-id')) ->icon('heroicon-s-plus') - ->action(function(){ + ->action(function () { $this->ownerRecord->tableCols()->create([ 'name' => 'id', 'type' => 'bigint', @@ -145,8 +160,8 @@ public function table(Table $table): Table ->color('info') ->requiresConfirmation() ->icon('heroicon-s-plus') - ->label('Add Timestamps') - ->action(function(){ + ->label(trans('filament-plugins::messages.tables.actions.add-timestamps')) + ->action(function () { $this->ownerRecord->tableCols()->createMany( [ [ @@ -166,8 +181,8 @@ public function table(Table $table): Table ->color('info') ->requiresConfirmation() ->icon('heroicon-s-plus') - ->label('Add Soft Deletes') - ->action(function(){ + ->label(trans('filament-plugins::messages.tables.actions.add-softdeletes')) + ->action(function () { $this->ownerRecord->tableCols()->create( [ 'name' => 'deleted_at', diff --git a/src/Services/Traits/GenerateInfo.php b/src/Services/Traits/GenerateInfo.php index 3569474..e9d6398 100644 --- a/src/Services/Traits/GenerateInfo.php +++ b/src/Services/Traits/GenerateInfo.php @@ -20,11 +20,17 @@ private function generateInfo(): void $module->title['ar'] = $this->title; $module->title['en'] = $this->title; $module->title['gr'] = $this->title; + $module->title['de'] = $this->title; + $module->title['nl'] = $this->title; + $module->title['fr'] = $this->title; $module->title['sp'] = $this->title; $module->description = []; $module->description['ar'] = $this->description; $module->description['en'] = $this->description; $module->description['gr'] = $this->description; + $module->description['de'] = $this->description; + $module->description['nl'] = $this->description; + $module->description['fr'] = $this->description; $module->description['sp'] = $this->description; $module->color = $this->color; $module->icon = $this->icon; diff --git a/stubs/FormBuilder/BuilderController.stub b/stubs/FormBuilder/BuilderController.stub index bbb034f..af56eaa 100644 --- a/stubs/FormBuilder/BuilderController.stub +++ b/stubs/FormBuilder/BuilderController.stub @@ -67,7 +67,7 @@ class {{ name }} extends Controller validation: [ {{ validation }} ], - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -119,7 +119,7 @@ class {{ name }} extends Controller validation: [ {{ validationEdit }} ], - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -138,7 +138,7 @@ class {{ name }} extends Controller { $response = Tomato::destroy( model: $model, - message: __('{{ title }} deleted successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.deleted_successfully'), redirect: 'admin.{{ table }}.index', ); diff --git a/stubs/FormBuilder/Form.stub b/stubs/FormBuilder/Form.stub index 4cfe4ea..5f41a92 100644 --- a/stubs/FormBuilder/Form.stub +++ b/stubs/FormBuilder/Form.stub @@ -1,3 +1,3 @@ - + diff --git a/stubs/FormBuilder/FormClass.stub b/stubs/FormBuilder/FormClass.stub index a7263a5..3510e83 100644 --- a/stubs/FormBuilder/FormClass.stub +++ b/stubs/FormBuilder/FormClass.stub @@ -28,7 +28,7 @@ class {{ name }} extends AbstractForm return [ {{ cols }} Submit::make() - ->label(__('Save')), + ->label(trans('filament-plugins::messages.plugins.save')), ]; } diff --git a/stubs/controller-request.stub b/stubs/controller-request.stub index 403b63e..3925b5a 100644 --- a/stubs/controller-request.stub +++ b/stubs/controller-request.stub @@ -63,7 +63,7 @@ class {{ name }} extends Controller $response = Tomato::store( request: $request, model: {{ model }}::class, - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -108,7 +108,7 @@ class {{ name }} extends Controller $response = Tomato::update( request: $request, model: $model, - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -127,7 +127,7 @@ class {{ name }} extends Controller { $response = Tomato::destroy( model: $model, - message: __('{{ title }} deleted successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.deleted_successfully'), redirect: 'admin.{{ table }}.index', ); diff --git a/stubs/controller.stub b/stubs/controller.stub index ac1402a..e8ce011 100644 --- a/stubs/controller.stub +++ b/stubs/controller.stub @@ -66,7 +66,7 @@ class {{ name }} extends Controller validation: [ {{ validation }} ], - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -114,7 +114,7 @@ class {{ name }} extends Controller validation: [ {{ validationEdit }} ], - message: __('{{ title }} updated successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.updated_successfully'), redirect: 'admin.{{ table }}.index', ); @@ -133,7 +133,7 @@ class {{ name }} extends Controller { $response = Tomato::destroy( model: $model, - message: __('{{ title }} deleted successfully'), + message: __('{{ title }}') trans('filament-plugins::messages.plugins.deleted_successfully'), redirect: 'admin.{{ table }}.index', ); diff --git a/stubs/create.stub b/stubs/create.stub index e9990fd..b8da04e 100644 --- a/stubs/create.stub +++ b/stubs/create.stub @@ -3,8 +3,8 @@ {{ cols }}
- - + +
diff --git a/stubs/edit.stub b/stubs/edit.stub index 3799d09..7065218 100644 --- a/stubs/edit.stub +++ b/stubs/edit.stub @@ -3,14 +3,14 @@ {{ cols }}
- + - + method="delete" label="{{trans('filament-plugins::messages.plugins.delete')}}" /> +
diff --git a/stubs/page.stub b/stubs/page.stub index 282bdef..abf2425 100644 --- a/stubs/page.stub +++ b/stubs/page.stub @@ -7,12 +7,17 @@ use Filament\Pages\Page; class {{ name }} extends Page { public static string $view = '{{ view }}'; - public static ?string $navigationGroup = '{{ title }}'; public static ?string $navigationLabel = '{{ title }}'; public static ?string $navigationIcon = '{{ icon }}'; public function getTitle(): string { - return '{{ title }}'; + return __('{{ title }}'); } + + public static function getNavigationGroup(): ?string + { + return __('{{ title }}'); + } + } diff --git a/stubs/table.stub b/stubs/table.stub index 66063d7..17117ea 100644 --- a/stubs/table.stub +++ b/stubs/table.stub @@ -58,7 +58,7 @@ class {{ name }} extends AbstractTable ->bulkAction( label: trans('tomato-admin::global.crud.delete'), each: fn ({{ model }} $model) => $model->delete(), - after: fn () => Toast::danger(__('{{ title }} Has Been Deleted'))->autoDismiss(2), + after: fn () => Toast::danger(__('{{ title }}') trans('filament-plugins::messages.plugins.has_been_deleted'))->autoDismiss(2), confirm: true ) ->defaultSort('id', 'desc') diff --git a/stubs/view.stub b/stubs/view.stub index 0fe1d98..d39e27a 100644 --- a/stubs/view.stub +++ b/stubs/view.stub @@ -3,13 +3,13 @@ {{ cols }}
- + - + method="delete" label="{{trans('filament-plugins::messages.plugins.delete')}}" /> +